@productbrain/mcp 0.0.1-beta.35 → 0.0.1-beta.36
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.
|
@@ -4797,9 +4797,23 @@ var CORE_PROTOCOL = [
|
|
|
4797
4797
|
"**Reference by ID.** When discussing a topic that has Chain entries, cite them by entry ID (e.g. `DEC-50`, `PRI-3`). This keeps conversations grounded in shared knowledge.",
|
|
4798
4798
|
"**Check scope.** If the proposed work doesn't fall under an active bet, stop and say so. Do not design implementation for out-of-scope work without explicit user go-ahead.",
|
|
4799
4799
|
`**Capture continuously.** When a decision, tension, insight, or new term surfaces during work, capture it as a draft immediately. Don't defer to "later."`,
|
|
4800
|
-
"**Validate against governance.** Before
|
|
4800
|
+
"**Validate against governance.** Before proposing any solution, check it against the Workspace Governance directives below. If your proposal conflicts with a principle, standard, or business rule \u2014 stop, name the conflict, and get explicit user confirmation before proceeding."
|
|
4801
4801
|
];
|
|
4802
|
-
|
|
4802
|
+
var MAX_ENTRIES_NO_TASK = 3;
|
|
4803
|
+
function extractKeywords(text) {
|
|
4804
|
+
return [...new Set(text.toLowerCase().split(/\s+/).filter((w) => w.length > 3))];
|
|
4805
|
+
}
|
|
4806
|
+
function scoreEntry(entry, keywords) {
|
|
4807
|
+
const text = `${entry.name} ${entry.description ?? ""}`.toLowerCase();
|
|
4808
|
+
return keywords.filter((kw) => text.includes(kw)).length;
|
|
4809
|
+
}
|
|
4810
|
+
function formatGovernanceEntry(entry) {
|
|
4811
|
+
const id = entry.entryId ?? entry.name;
|
|
4812
|
+
const desc = entry.description ? ` \u2014 ${entry.description.slice(0, 120)}${entry.description.length > 120 ? "..." : ""}` : "";
|
|
4813
|
+
return `- **[${id}]** ${entry.name}${desc}`;
|
|
4814
|
+
}
|
|
4815
|
+
function buildOperatingProtocol(governanceOrStandards, task) {
|
|
4816
|
+
const governance = Array.isArray(governanceOrStandards) ? { standards: governanceOrStandards } : governanceOrStandards ?? {};
|
|
4803
4817
|
const lines = [
|
|
4804
4818
|
"## Operating Protocol",
|
|
4805
4819
|
"_How to work in this workspace. Follow these before and during every task._",
|
|
@@ -4808,13 +4822,56 @@ function buildOperatingProtocol(workspaceStandards) {
|
|
|
4808
4822
|
for (let i = 0; i < CORE_PROTOCOL.length; i++) {
|
|
4809
4823
|
lines.push(`${i + 1}. ${CORE_PROTOCOL[i]}`);
|
|
4810
4824
|
}
|
|
4811
|
-
|
|
4825
|
+
const { principles = [], standards = [], businessRules = [] } = governance;
|
|
4826
|
+
const hasGovernance = principles.length > 0 || standards.length > 0 || businessRules.length > 0;
|
|
4827
|
+
if (hasGovernance) {
|
|
4812
4828
|
lines.push("");
|
|
4813
|
-
lines.push("
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4829
|
+
lines.push("### Workspace governance directives");
|
|
4830
|
+
const types = [
|
|
4831
|
+
{ header: "**Active principles:**", entries: principles },
|
|
4832
|
+
{ header: "**Active business rules:**", entries: businessRules },
|
|
4833
|
+
{ header: "**Active standards:**", entries: standards }
|
|
4834
|
+
];
|
|
4835
|
+
if (task) {
|
|
4836
|
+
const keywords = extractKeywords(task);
|
|
4837
|
+
let anyRelevant = false;
|
|
4838
|
+
for (const type of types) {
|
|
4839
|
+
if (type.entries.length === 0) continue;
|
|
4840
|
+
const scored = type.entries.map((e) => ({ entry: e, score: scoreEntry(e, keywords) })).filter((s) => s.score > 0).sort((a, b) => b.score - a.score);
|
|
4841
|
+
if (scored.length > 0) {
|
|
4842
|
+
anyRelevant = true;
|
|
4843
|
+
lines.push(type.header);
|
|
4844
|
+
for (const s of scored) {
|
|
4845
|
+
lines.push(formatGovernanceEntry(s.entry));
|
|
4846
|
+
}
|
|
4847
|
+
lines.push("");
|
|
4848
|
+
}
|
|
4849
|
+
}
|
|
4850
|
+
if (!anyRelevant) {
|
|
4851
|
+
for (const type of types) {
|
|
4852
|
+
if (type.entries.length === 0) continue;
|
|
4853
|
+
lines.push(type.header);
|
|
4854
|
+
for (const e of type.entries.slice(0, MAX_ENTRIES_NO_TASK)) {
|
|
4855
|
+
lines.push(formatGovernanceEntry(e));
|
|
4856
|
+
}
|
|
4857
|
+
lines.push("");
|
|
4858
|
+
}
|
|
4859
|
+
}
|
|
4860
|
+
lines.push(
|
|
4861
|
+
"_Governance filtered by task relevance. Run `orient` without a task to see all._"
|
|
4862
|
+
);
|
|
4863
|
+
} else {
|
|
4864
|
+
for (const type of types) {
|
|
4865
|
+
if (type.entries.length === 0) continue;
|
|
4866
|
+
lines.push(type.header);
|
|
4867
|
+
for (const e of type.entries.slice(0, MAX_ENTRIES_NO_TASK)) {
|
|
4868
|
+
lines.push(formatGovernanceEntry(e));
|
|
4869
|
+
}
|
|
4870
|
+
lines.push("");
|
|
4871
|
+
}
|
|
4872
|
+
lines.push(
|
|
4873
|
+
'_Showing top governance entries. Use `orient task="..."` for task-relevant filtering._'
|
|
4874
|
+
);
|
|
4818
4875
|
}
|
|
4819
4876
|
}
|
|
4820
4877
|
lines.push("");
|
|
@@ -5048,7 +5105,9 @@ async function buildOrientResponse(wsCtx, agentSessionId, errors) {
|
|
|
5048
5105
|
if (readiness) {
|
|
5049
5106
|
lines.push(`Readiness: ${readiness.score}% (${readiness.passedChecks}/${readiness.totalChecks}).`);
|
|
5050
5107
|
}
|
|
5108
|
+
let wsPrinciples = [];
|
|
5051
5109
|
let wsStandards = [];
|
|
5110
|
+
let wsBusinessRules = [];
|
|
5052
5111
|
try {
|
|
5053
5112
|
const govSlugs = ["principles", "standards", "business-rules"];
|
|
5054
5113
|
const govLabels = {
|
|
@@ -5062,7 +5121,9 @@ async function buildOrientResponse(wsCtx, agentSessionId, errors) {
|
|
|
5062
5121
|
const active = (entries ?? []).filter((e) => e.status === "active" || e.status === "verified");
|
|
5063
5122
|
if (active.length > 0) {
|
|
5064
5123
|
govEntries.push({ slug, entries: active });
|
|
5124
|
+
if (slug === "principles") wsPrinciples = active;
|
|
5065
5125
|
if (slug === "standards") wsStandards = active;
|
|
5126
|
+
if (slug === "business-rules") wsBusinessRules = active;
|
|
5066
5127
|
}
|
|
5067
5128
|
}
|
|
5068
5129
|
if (govEntries.length > 0) {
|
|
@@ -5096,12 +5157,16 @@ async function buildOrientResponse(wsCtx, agentSessionId, errors) {
|
|
|
5096
5157
|
}
|
|
5097
5158
|
} catch {
|
|
5098
5159
|
}
|
|
5099
|
-
const
|
|
5160
|
+
const mapGovEntry = (e) => ({
|
|
5100
5161
|
entryId: e.entryId,
|
|
5101
5162
|
name: e.name,
|
|
5102
5163
|
description: typeof e.data?.description === "string" ? e.data.description : typeof e.description === "string" ? e.description : void 0
|
|
5164
|
+
});
|
|
5165
|
+
lines.push(...buildOperatingProtocol({
|
|
5166
|
+
principles: wsPrinciples.map(mapGovEntry),
|
|
5167
|
+
standards: wsStandards.map(mapGovEntry),
|
|
5168
|
+
businessRules: wsBusinessRules.map(mapGovEntry)
|
|
5103
5169
|
}));
|
|
5104
|
-
lines.push(...buildOperatingProtocol(standardsForProtocol));
|
|
5105
5170
|
const plannedWork = await queryPlannedWork();
|
|
5106
5171
|
if (hasPlannedWork(plannedWork)) {
|
|
5107
5172
|
lines.push("");
|
|
@@ -7376,12 +7441,16 @@ function registerHealthTools(server) {
|
|
|
7376
7441
|
orientEntries.architectureNotes.forEach((e) => lines.push(fmt(e)));
|
|
7377
7442
|
lines.push("");
|
|
7378
7443
|
}
|
|
7379
|
-
const
|
|
7444
|
+
const mapGovernanceEntry = (e) => ({
|
|
7380
7445
|
entryId: e.entryId,
|
|
7381
7446
|
name: e.name,
|
|
7382
7447
|
description: typeof e.preview === "string" ? e.preview : void 0
|
|
7383
|
-
})
|
|
7384
|
-
lines.push(...buildOperatingProtocol(
|
|
7448
|
+
});
|
|
7449
|
+
lines.push(...buildOperatingProtocol({
|
|
7450
|
+
principles: (orientEntries.principles ?? []).map(mapGovernanceEntry),
|
|
7451
|
+
standards: (orientEntries.standards ?? []).map(mapGovernanceEntry),
|
|
7452
|
+
businessRules: (orientEntries.businessRules ?? []).map(mapGovernanceEntry)
|
|
7453
|
+
}, task));
|
|
7385
7454
|
}
|
|
7386
7455
|
const plannedWork = await queryPlannedWork();
|
|
7387
7456
|
if (hasPlannedWork(plannedWork)) {
|
|
@@ -8587,4 +8656,4 @@ export {
|
|
|
8587
8656
|
SERVER_VERSION,
|
|
8588
8657
|
createProductBrainServer
|
|
8589
8658
|
};
|
|
8590
|
-
//# sourceMappingURL=chunk-
|
|
8659
|
+
//# sourceMappingURL=chunk-VEU5BI7L.js.map
|