@productbrain/mcp 0.0.1-beta.15354 → 0.0.1-beta.15371
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.
|
@@ -816,6 +816,9 @@ var TRUST_STATUS_LABELS = {
|
|
|
816
816
|
active: "Accepted",
|
|
817
817
|
deprecated: "Archived"
|
|
818
818
|
};
|
|
819
|
+
function entryStatusLabel(word) {
|
|
820
|
+
return word.split(/[_-]/).filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(" ");
|
|
821
|
+
}
|
|
819
822
|
var ENTRY_STATUS_READ_WORDS = ["draft", ...TRUST_ACCEPTED_WORDS, ...TRUST_ARCHIVED_WORDS];
|
|
820
823
|
var ENTRY_STATUS_WRITE_WORDS = ["draft", "archived"];
|
|
821
824
|
|
|
@@ -3644,7 +3647,22 @@ function priorityOf(value) {
|
|
|
3644
3647
|
return typeof value === "string" && Object.prototype.hasOwnProperty.call(PRIORITY_LEVELS, value) ? value : null;
|
|
3645
3648
|
}
|
|
3646
3649
|
|
|
3650
|
+
// src/lib/dateValidation.ts
|
|
3651
|
+
var ISO_DATE_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/;
|
|
3652
|
+
function isValidISODate(value) {
|
|
3653
|
+
if (typeof value !== "string") return false;
|
|
3654
|
+
if (!ISO_DATE_REGEX.test(value)) return false;
|
|
3655
|
+
const parts = value.split("-");
|
|
3656
|
+
const year = Number(parts[0]);
|
|
3657
|
+
const month = Number(parts[1]);
|
|
3658
|
+
const day = Number(parts[2]);
|
|
3659
|
+
const date = new Date(year, month - 1, day);
|
|
3660
|
+
return date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day;
|
|
3661
|
+
}
|
|
3662
|
+
|
|
3647
3663
|
// src/lib/taskDue.ts
|
|
3664
|
+
var DAY = 864e5;
|
|
3665
|
+
var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
3648
3666
|
var STATE_WORDS = { overdue: "Overdue", dueToday: "Due today", due: "Due" };
|
|
3649
3667
|
var TASK_DUE_WORDS = {
|
|
3650
3668
|
...STATE_WORDS,
|
|
@@ -3655,6 +3673,21 @@ var TASK_DUE_WORDS = {
|
|
|
3655
3673
|
/** Orient's counts line (RULE-17): the denominator is the open tasks the read judged, and a cut read says capped. */
|
|
3656
3674
|
counts: (overdue, dueToday, read, capped) => `${overdue} ${STATE_WORDS.overdue}, ${dueToday} ${STATE_WORDS.dueToday} of ${read} open read${capped ? ", capped" : ""}.`
|
|
3657
3675
|
};
|
|
3676
|
+
function utcDay(date) {
|
|
3677
|
+
return isValidISODate(date) ? Math.floor(Date.parse(date) / DAY) : null;
|
|
3678
|
+
}
|
|
3679
|
+
function dayText(dueDate, now) {
|
|
3680
|
+
const [year, month, day] = dueDate.split("-").map(Number);
|
|
3681
|
+
return `${day} ${MONTHS[month - 1]}${year === new Date(now).getUTCFullYear() ? "" : ` ${year}`}`;
|
|
3682
|
+
}
|
|
3683
|
+
function taskDue(input) {
|
|
3684
|
+
const due = utcDay(input.dueDate);
|
|
3685
|
+
if (!input.open || due === null) return null;
|
|
3686
|
+
const days = due - Math.floor(input.now / DAY);
|
|
3687
|
+
const key = days < 0 ? "overdue" : days === 0 ? "dueToday" : "due";
|
|
3688
|
+
const day = dayText(input.dueDate, input.now);
|
|
3689
|
+
return { key, word: STATE_WORDS[key], day, line: TASK_DUE_WORDS.line(day) };
|
|
3690
|
+
}
|
|
3658
3691
|
function taskDueMark(due) {
|
|
3659
3692
|
return due.key === "overdue" ? `${due.word}, ${due.line}` : due.key === "dueToday" ? due.word : due.line;
|
|
3660
3693
|
}
|
|
@@ -3675,6 +3708,11 @@ var WORK_PACKAGE_LIST_WORDS = {
|
|
|
3675
3708
|
listHeading: "Live work packages",
|
|
3676
3709
|
/** That list's last line when it stopped at its cap; the brief has no way to continue past it. */
|
|
3677
3710
|
listStops: (cap) => `More than ${cap} live packages; the list stops here.`,
|
|
3711
|
+
/** 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. */
|
|
3712
|
+
ticks: (ticked, total) => total === 0 ? "no done-when" : `${ticked} of ${total} done-when ticked`,
|
|
3713
|
+
noStage: "no stage",
|
|
3714
|
+
/** After the ticks of a live package whose every item is ticked, so a reader closes it or adds what is left (TASK-1872). */
|
|
3715
|
+
allTicked: "(all ticked: close it, or add what is left)",
|
|
3678
3716
|
/** A tension linked to a row, named and with its id so a reader can open it; each surface adds its own indent. */
|
|
3679
3717
|
tension: (t) => `\u21B3 tension${t.entryId ? ` ${t.entryId}` : ""}: ${t.name}`,
|
|
3680
3718
|
setOne: "Set one (urgent, high, medium or low):",
|
|
@@ -3703,6 +3741,28 @@ function workPackageListLines(rows, counts, surface) {
|
|
|
3703
3741
|
}
|
|
3704
3742
|
return lines;
|
|
3705
3743
|
}
|
|
3744
|
+
function doneWhenTicks(value) {
|
|
3745
|
+
const items = Array.isArray(value) ? value : [];
|
|
3746
|
+
return { ticked: items.filter((item) => typeof item === "object" && item !== null && item.done === true).length, total: items.length };
|
|
3747
|
+
}
|
|
3748
|
+
function liveWorkPackageRowText(row, now) {
|
|
3749
|
+
const w = WORK_PACKAGE_LIST_WORDS, sep = OPEN_TASK_LIST_WORDS.separator;
|
|
3750
|
+
const { ticked, total } = doneWhenTicks(row.data?.["doneWhen"]);
|
|
3751
|
+
const due = taskDue({ dueDate: row.data?.["dueDate"], open: true, now });
|
|
3752
|
+
return `${row.entryId ? `${row.entryId} \u2014 ` : ""}${row.name}${sep}${row.workflowStatus ? entryStatusLabel(row.workflowStatus) : w.noStage}${sep}${w.ticks(ticked, total)}${total > 0 && ticked === total ? ` ${w.allTicked}` : ""}${due ? `${sep}${taskDueMark(due)}` : ""}`;
|
|
3753
|
+
}
|
|
3754
|
+
function liveWorkPackageLines(rows, surface, now) {
|
|
3755
|
+
const marked = rows.map((row) => {
|
|
3756
|
+
const priority = priorityOf(row.data?.["priority"]);
|
|
3757
|
+
return { ...row, ...priority ? { priority } : {} };
|
|
3758
|
+
});
|
|
3759
|
+
return workPackageListLines(marked, void 0, {
|
|
3760
|
+
heading: surface.heading,
|
|
3761
|
+
setCommand: WORK_PACKAGE_LIST_WORDS.setCommand[surface.surface],
|
|
3762
|
+
allCommand: WORK_PACKAGE_LIST_WORDS.allCommand[surface.surface],
|
|
3763
|
+
row: (row) => [`${surface.bullet}${liveWorkPackageRowText(row, now)}`]
|
|
3764
|
+
});
|
|
3765
|
+
}
|
|
3706
3766
|
var OPEN_TASK_LIST_WORDS = {
|
|
3707
3767
|
heading: (roleName) => `${roleName}'s open tasks: due ones first, then those in no live work package`,
|
|
3708
3768
|
separator: " \xB7 ",
|
|
@@ -5743,14 +5803,8 @@ function formatConfidencePass(result2) {
|
|
|
5743
5803
|
""
|
|
5744
5804
|
];
|
|
5745
5805
|
lines.push(`## ${WORK_PACKAGE_LIST_WORDS.listHeading} (${result2.workPackageCount})`);
|
|
5746
|
-
if (result2.activeBets.length > 0) {
|
|
5747
|
-
|
|
5748
|
-
const id = bet.entryId ? `**${bet.entryId}:** ` : "";
|
|
5749
|
-
lines.push(`- ${id}${bet.name} [${bet.status}]`);
|
|
5750
|
-
}
|
|
5751
|
-
} else {
|
|
5752
|
-
lines.push("_No active work packages._");
|
|
5753
|
-
}
|
|
5806
|
+
if (result2.activeBets.length > 0) lines.push(...liveWorkPackageLines(result2.activeBets, { heading: (word) => `**${word}**`, bullet: "- ", surface: "mcp" }, Date.now()));
|
|
5807
|
+
else lines.push("_No active work packages._");
|
|
5754
5808
|
lines.push(...result2.workPackagesTruncated ? [WORK_PACKAGE_LIST_WORDS.listStops(result2.workPackageCount)] : [], "");
|
|
5755
5809
|
lines.push("_Tensions: see `pb tensions list` on the CLI \u2014 this pass no longer carries a tension count._");
|
|
5756
5810
|
lines.push("");
|
|
@@ -7196,9 +7250,7 @@ function parseWorkspaceScopeBinding(raw) {
|
|
|
7196
7250
|
var BIND_AGAIN = "npm run workspace:bind -- <WP-ID> [TASK-ID ...]";
|
|
7197
7251
|
var BOUND_SCOPE_WORDS = {
|
|
7198
7252
|
heading: "## Bound scope",
|
|
7199
|
-
|
|
7200
|
-
ticks: (ticked, total) => total === 0 ? "no done-when" : `${ticked} of ${total} done-when ticked`,
|
|
7201
|
-
noStage: "no stage",
|
|
7253
|
+
// a task's ticks and "no stage" come from WORK_PACKAGE_LIST_WORDS, shared with the brief's rows (TASK-1872)
|
|
7202
7254
|
notFound: "not found in this workspace; check the id in the bind file, or bind again",
|
|
7203
7255
|
/** The credential reads another workspace than the lane was bound in (as assertParentIdentity refuses in the lane scripts). */
|
|
7204
7256
|
otherWorkspace: (ids) => `Read from another workspace than this lane's bind: ${ids.join(", ")}. Run \`pb profile use <name>\` for the lane's workspace, or bind again: ${BIND_AGAIN}`,
|
|
@@ -7242,12 +7294,11 @@ function rowOf(entryId, answer2, isTask, workspaceId) {
|
|
|
7242
7294
|
if (!isRecord(entry)) return { entryId, notRead: BOUND_SCOPE_WORDS.notFound };
|
|
7243
7295
|
if (entry["workspaceId"] !== workspaceId) return { entryId, otherWorkspace: true };
|
|
7244
7296
|
const data = isRecord(entry["data"]) ? entry["data"] : {};
|
|
7245
|
-
const items = Array.isArray(data["doneWhen"]) ? data["doneWhen"] : [];
|
|
7246
7297
|
return {
|
|
7247
7298
|
entryId,
|
|
7248
7299
|
...typeof entry["name"] === "string" ? { name: entry["name"] } : {},
|
|
7249
7300
|
...typeof entry["workflowStatus"] === "string" ? { workflowStatus: entry["workflowStatus"] } : {},
|
|
7250
|
-
...isTask ? { doneWhen:
|
|
7301
|
+
...isTask ? { doneWhen: doneWhenTicks(data["doneWhen"]) } : { priority: data["priority"] }
|
|
7251
7302
|
};
|
|
7252
7303
|
}
|
|
7253
7304
|
async function readRows(io, ids, workspaceId) {
|
|
@@ -7295,8 +7346,8 @@ async function readBoundScope(io) {
|
|
|
7295
7346
|
function rowLine(row, isTask) {
|
|
7296
7347
|
if (row.notRead) return BOUND_SCOPE_WORDS.notRead(row.entryId, row.notRead);
|
|
7297
7348
|
const token = priorityOf(row.priority);
|
|
7298
|
-
const tail = isTask ?
|
|
7299
|
-
return `${row.entryId}${row.name ? ` \u2014 ${row.name}` : ""} \xB7 ${row.workflowStatus
|
|
7349
|
+
const tail = isTask ? WORK_PACKAGE_LIST_WORDS.ticks(row.doneWhen?.ticked ?? 0, row.doneWhen?.total ?? 0) : token ? PRIORITY_LEVELS[token].word : NO_PRIORITY.word;
|
|
7350
|
+
return `${row.entryId}${row.name ? ` \u2014 ${row.name}` : ""} \xB7 ${row.workflowStatus ? entryStatusLabel(row.workflowStatus) : WORK_PACKAGE_LIST_WORDS.noStage} \xB7 ${tail}`;
|
|
7300
7351
|
}
|
|
7301
7352
|
function boundScopeLines(view) {
|
|
7302
7353
|
const lines = [BOUND_SCOPE_WORDS.heading, ""];
|
|
@@ -12499,4 +12550,4 @@ export {
|
|
|
12499
12550
|
SERVER_VERSION,
|
|
12500
12551
|
createProductBrainServer
|
|
12501
12552
|
};
|
|
12502
|
-
//# sourceMappingURL=chunk-
|
|
12553
|
+
//# sourceMappingURL=chunk-TO4LW22Q.js.map
|