@productbrain/mcp 0.0.1-beta.9286 → 0.0.1-beta.9307
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.
|
@@ -828,94 +828,6 @@ async function isGoverned(slug) {
|
|
|
828
828
|
return !!col?.governed;
|
|
829
829
|
}
|
|
830
830
|
|
|
831
|
-
// src/lib/textMatch.ts
|
|
832
|
-
var STOP_WORDS = /* @__PURE__ */ new Set([
|
|
833
|
-
"the",
|
|
834
|
-
"and",
|
|
835
|
-
"for",
|
|
836
|
-
"are",
|
|
837
|
-
"but",
|
|
838
|
-
"not",
|
|
839
|
-
"you",
|
|
840
|
-
"all",
|
|
841
|
-
"can",
|
|
842
|
-
"has",
|
|
843
|
-
"her",
|
|
844
|
-
"was",
|
|
845
|
-
"one",
|
|
846
|
-
"our",
|
|
847
|
-
"out",
|
|
848
|
-
"day",
|
|
849
|
-
"had",
|
|
850
|
-
"hot",
|
|
851
|
-
"how",
|
|
852
|
-
"its",
|
|
853
|
-
"may",
|
|
854
|
-
"new",
|
|
855
|
-
"now",
|
|
856
|
-
"old",
|
|
857
|
-
"see",
|
|
858
|
-
"way",
|
|
859
|
-
"who",
|
|
860
|
-
"did",
|
|
861
|
-
"get",
|
|
862
|
-
"let",
|
|
863
|
-
"say",
|
|
864
|
-
"she",
|
|
865
|
-
"too",
|
|
866
|
-
"use",
|
|
867
|
-
"from",
|
|
868
|
-
"have",
|
|
869
|
-
"been",
|
|
870
|
-
"each",
|
|
871
|
-
"that",
|
|
872
|
-
"this",
|
|
873
|
-
"with",
|
|
874
|
-
"will",
|
|
875
|
-
"they",
|
|
876
|
-
"what",
|
|
877
|
-
"when",
|
|
878
|
-
"make",
|
|
879
|
-
"like",
|
|
880
|
-
"long",
|
|
881
|
-
"look",
|
|
882
|
-
"many",
|
|
883
|
-
"some",
|
|
884
|
-
"them",
|
|
885
|
-
"than",
|
|
886
|
-
"most",
|
|
887
|
-
"only",
|
|
888
|
-
"over",
|
|
889
|
-
"such",
|
|
890
|
-
"into",
|
|
891
|
-
"also",
|
|
892
|
-
"back",
|
|
893
|
-
"just",
|
|
894
|
-
"much",
|
|
895
|
-
"must",
|
|
896
|
-
"name",
|
|
897
|
-
"very",
|
|
898
|
-
"your",
|
|
899
|
-
"after",
|
|
900
|
-
"which",
|
|
901
|
-
"their",
|
|
902
|
-
"about",
|
|
903
|
-
"would",
|
|
904
|
-
"there",
|
|
905
|
-
"should",
|
|
906
|
-
"could",
|
|
907
|
-
"other",
|
|
908
|
-
"these",
|
|
909
|
-
"first",
|
|
910
|
-
"being",
|
|
911
|
-
"those",
|
|
912
|
-
"still",
|
|
913
|
-
"where"
|
|
914
|
-
]);
|
|
915
|
-
function tokenizeText(input) {
|
|
916
|
-
return input.toLowerCase().replace(/[^\p{L}\p{N}\s]+/gu, " ").split(/\s+/).filter(Boolean);
|
|
917
|
-
}
|
|
918
|
-
|
|
919
831
|
// src/lib/entryDataNormalization.ts
|
|
920
832
|
function buildDataFromFields(fields, descriptionField, descriptionValue) {
|
|
921
833
|
if (!descriptionField) return null;
|
|
@@ -1020,7 +932,6 @@ function buildCaptureForRealNextAction(payload) {
|
|
|
1020
932
|
name,
|
|
1021
933
|
description,
|
|
1022
934
|
context,
|
|
1023
|
-
entryId,
|
|
1024
935
|
canonicalKey,
|
|
1025
936
|
data,
|
|
1026
937
|
links,
|
|
@@ -1037,7 +948,6 @@ function buildCaptureForRealNextAction(payload) {
|
|
|
1037
948
|
name,
|
|
1038
949
|
description,
|
|
1039
950
|
...context ? { context } : {},
|
|
1040
|
-
...entryId ? { entryId } : {},
|
|
1041
951
|
...canonicalKey ? { canonicalKey } : {},
|
|
1042
952
|
...data && Object.keys(data).length > 0 ? { data } : {},
|
|
1043
953
|
...links && links.length > 0 ? { links } : {},
|
|
@@ -1266,14 +1176,11 @@ function invalidateProfileCacheForScope() {
|
|
|
1266
1176
|
}
|
|
1267
1177
|
var SPINE_FLOOR_SENTENCE = "kept as a draft; it can be accepted once its spine above is accepted \u2014 the promote door checks the whole spine and names the first missing rung.";
|
|
1268
1178
|
var SPINE_FLOOR_EXEMPT_SENTENCE = "kept as a draft, though this workspace is not yet enforcing the spine above it \u2014 it can be accepted as-is.";
|
|
1269
|
-
var BR_STD_ENTRY_ID_REGEX = /^(BR|STD)-\d+$/;
|
|
1270
|
-
var entryIdSchema = z4.string().regex(BR_STD_ENTRY_ID_REGEX).optional().describe("Only for business-rules and standards. Must match BR-NNN or STD-NNN. Omit for all other collections \u2014 IDs are auto-generated.");
|
|
1271
1179
|
var captureSchema = z4.object({
|
|
1272
|
-
collection: z4.string().optional().describe("Collection slug, e.g. 'tensions', '
|
|
1180
|
+
collection: z4.string().optional().describe("Collection slug, e.g. 'tensions', 'rules', 'glossary', 'decisions'. Optional \u2014 classifier auto-routes when omitted."),
|
|
1273
1181
|
name: z4.string().describe("Display name \u2014 be specific (e.g. 'Convex adjacency list won't scale for graph traversal')"),
|
|
1274
1182
|
description: z4.string().describe("Full context \u2014 what's happening, why it matters, what you observed"),
|
|
1275
1183
|
context: z4.string().optional().describe("Optional additional context (e.g. 'Observed during context gather calls taking 700ms+')"),
|
|
1276
|
-
entryId: entryIdSchema,
|
|
1277
1184
|
canonicalKey: z4.string().optional().describe("Semantic type (e.g. 'decision', 'tension', 'vision'). Auto-assigned from collection if omitted."),
|
|
1278
1185
|
data: z4.record(z4.unknown()).optional().describe("Explicit field values when you know the schema (e.g. canonical_key, cardinality_rule, required_fields). Merged with inferred values; user-provided wins."),
|
|
1279
1186
|
why: z4.string().optional().describe("Reasoning behind this entry \u2014 hard-required for purpose/vision/strategy/objective/decision/rule/key_result/product."),
|
|
@@ -1583,11 +1490,10 @@ var CAPTURE_ACTIONS = ["capture"];
|
|
|
1583
1490
|
var SUGGEST_ONLY_REMOVED = "suggestOnly was removed: call capture with preview: true to check a capture without writing.";
|
|
1584
1491
|
var captureCompoundSchema = z4.object({
|
|
1585
1492
|
action: z4.enum(CAPTURE_ACTIONS).optional().default("capture").describe("Create a single knowledge entry."),
|
|
1586
|
-
collection: z4.string().max(200).optional().describe("Collection slug, e.g. 'tensions', '
|
|
1493
|
+
collection: z4.string().max(200).optional().describe("Collection slug, e.g. 'tensions', 'rules', 'glossary', 'decisions'. Optional \u2014 classifier auto-routes when omitted."),
|
|
1587
1494
|
name: z4.string().max(ENTRY_NAME_MAX_CHARS).optional().describe("Display name \u2014 required."),
|
|
1588
1495
|
description: z4.string().max(ENTRY_BODY_MAX_CHARS).optional().describe("Full context \u2014 required."),
|
|
1589
1496
|
context: z4.string().max(5e3).optional().describe("Optional additional context."),
|
|
1590
|
-
entryId: entryIdSchema,
|
|
1591
1497
|
canonicalKey: z4.string().max(200).optional().describe("Semantic type (e.g. 'decision', 'tension', 'vision'). Auto-assigned from collection if omitted."),
|
|
1592
1498
|
data: z4.record(z4.unknown()).optional().describe("Explicit field values; user-provided wins over inferred."),
|
|
1593
1499
|
why: z4.string().max(ENTRY_BODY_MAX_CHARS).optional().describe("Why this entry exists."),
|
|
@@ -1610,7 +1516,7 @@ var captureActionUnion = z4.discriminatedUnion("action", [
|
|
|
1610
1516
|
]);
|
|
1611
1517
|
var CAPTURE_ACTION_SPECS = {
|
|
1612
1518
|
capture: {
|
|
1613
|
-
params: ["collection", "name", "description", "context", "
|
|
1519
|
+
params: ["collection", "name", "description", "context", "canonicalKey", "data", "why", "links", "sourceRef", "sourceExcerpt", "preview"],
|
|
1614
1520
|
description: "name and description are required."
|
|
1615
1521
|
}
|
|
1616
1522
|
};
|
|
@@ -1644,7 +1550,7 @@ All other collections get an ENT-{random} ID and sensible defaults.
|
|
|
1644
1550
|
})
|
|
1645
1551
|
);
|
|
1646
1552
|
}
|
|
1647
|
-
async function handleCapture(server, { collection, name, description, context,
|
|
1553
|
+
async function handleCapture(server, { collection, name, description, context, canonicalKey, data: userData, why, links, sourceRef, sourceExcerpt, preview, ownerRoleEntryId }) {
|
|
1648
1554
|
requireWriteAccess();
|
|
1649
1555
|
const timingStart = Date.now();
|
|
1650
1556
|
const wsCtx = await getWorkspaceContext();
|
|
@@ -1698,23 +1604,6 @@ async function handleCapture(server, { collection, name, description, context, e
|
|
|
1698
1604
|
)
|
|
1699
1605
|
};
|
|
1700
1606
|
}
|
|
1701
|
-
if (entryId && resolvedCollection !== "business-rules" && resolvedCollection !== "standards") {
|
|
1702
|
-
return {
|
|
1703
|
-
content: [{
|
|
1704
|
-
type: "text",
|
|
1705
|
-
// BR-111
|
|
1706
|
-
text: `# entryId Not Allowed
|
|
1707
|
-
|
|
1708
|
-
\`entryId\` is only valid for \`business-rules\` and \`standards\` collections. For \`${resolvedCollection}\`, omit \`entryId\` \u2014 IDs are auto-generated.`
|
|
1709
|
-
}],
|
|
1710
|
-
structuredContent: failure(
|
|
1711
|
-
"INVALID_ENTRY_ID",
|
|
1712
|
-
`entryId is only allowed for business-rules and standards. Omit for ${resolvedCollection}.`,
|
|
1713
|
-
"Remove entryId from your capture call.",
|
|
1714
|
-
[]
|
|
1715
|
-
)
|
|
1716
|
-
};
|
|
1717
|
-
}
|
|
1718
1607
|
const profile = await getProfile(resolvedCollection, col.fields);
|
|
1719
1608
|
userData = await foldWhyIntoData(resolvedCollection, why, userData);
|
|
1720
1609
|
const groundingStart = Date.now();
|
|
@@ -1802,7 +1691,6 @@ async function handleCapture(server, { collection, name, description, context, e
|
|
|
1802
1691
|
try {
|
|
1803
1692
|
const result2 = await kernelMutation("chain.createEntry", {
|
|
1804
1693
|
collectionSlug: resolvedCollection,
|
|
1805
|
-
entryId: entryId ?? void 0,
|
|
1806
1694
|
name,
|
|
1807
1695
|
// DEC-896 / BR-76: omit status — server resolves from governanceMode (Open→active, else draft).
|
|
1808
1696
|
data,
|
|
@@ -1858,7 +1746,6 @@ async function handleCapture(server, { collection, name, description, context, e
|
|
|
1858
1746
|
name,
|
|
1859
1747
|
description,
|
|
1860
1748
|
context,
|
|
1861
|
-
entryId,
|
|
1862
1749
|
canonicalKey,
|
|
1863
1750
|
data: userData,
|
|
1864
1751
|
links,
|
|
@@ -1913,8 +1800,8 @@ Use \`entries action=get\` to inspect the existing entry, or \`entries action=up
|
|
|
1913
1800
|
msg,
|
|
1914
1801
|
"Use entries action=get to inspect the existing entry.",
|
|
1915
1802
|
[
|
|
1916
|
-
{ tool: "entries", description: "Get existing entry", parameters: { action: "get", entryId:
|
|
1917
|
-
{ tool: "entries", description: "Update existing entry", parameters: { action: "update", entryId:
|
|
1803
|
+
{ tool: "entries", description: "Get existing entry", parameters: { action: "get", entryId: name } },
|
|
1804
|
+
{ tool: "entries", description: "Update existing entry", parameters: { action: "update", entryId: "" } }
|
|
1918
1805
|
]
|
|
1919
1806
|
)
|
|
1920
1807
|
};
|
|
@@ -1963,15 +1850,13 @@ Use \`entries action=get\` to inspect the existing entry, or \`entries action=up
|
|
|
1963
1850
|
return null;
|
|
1964
1851
|
}) : Promise.resolve(null);
|
|
1965
1852
|
const cardinalityPromise = resolvedCK ? kernelQuery("chain.checkCardinalityWarning", { canonicalKey: resolvedCK, excludeEntryId: internalId }).catch(() => null) : Promise.resolve(null);
|
|
1966
|
-
const contradictionPromise = runContradictionCheck(name, description, finalEntryId, internalId);
|
|
1967
1853
|
const coachingPromise = coachingFromCreate !== void 0 ? Promise.resolve(coachingFromCreate) : kernelMutation("quality.evaluateHeuristicAndSchedule", {
|
|
1968
1854
|
entryId: finalEntryId,
|
|
1969
1855
|
context: "capture"
|
|
1970
1856
|
}).catch(() => null);
|
|
1971
|
-
const [batchResult, cardinalityCheck,
|
|
1857
|
+
const [batchResult, cardinalityCheck, coachingAtCreate] = await Promise.all([
|
|
1972
1858
|
batchRelationsPromise,
|
|
1973
1859
|
cardinalityPromise,
|
|
1974
|
-
contradictionPromise,
|
|
1975
1860
|
coachingPromise
|
|
1976
1861
|
]);
|
|
1977
1862
|
let verdictResult = coachingAtCreate;
|
|
@@ -2003,9 +1888,6 @@ Use \`entries action=get\` to inspect the existing entry, or \`entries action=up
|
|
|
2003
1888
|
}
|
|
2004
1889
|
const tAfterQuality = Date.now();
|
|
2005
1890
|
const cardinalityWarning = cardinalityCheck?.warning ?? null;
|
|
2006
|
-
if (contradictionWarnings.length > 0) {
|
|
2007
|
-
await recordSessionActivity({ contradictionWarning: true });
|
|
2008
|
-
}
|
|
2009
1891
|
let coachingSection = "";
|
|
2010
1892
|
if (verdictResult?.verdict && verdictResult.verdict.tier !== "passive" && verdictResult.verdict.criteria.length > 0) {
|
|
2011
1893
|
coachingSection = formatRubricCoaching(verdictResult);
|
|
@@ -2127,14 +2009,6 @@ Use \`entries action=get\` to inspect the existing entry, or \`entries action=up
|
|
|
2127
2009
|
lines.push("");
|
|
2128
2010
|
lines.push(`**Cardinality warning:** ${cardinalityWarning}`);
|
|
2129
2011
|
}
|
|
2130
|
-
if (contradictionWarnings.length > 0) {
|
|
2131
|
-
lines.push("");
|
|
2132
|
-
lines.push("\u26A0 Contradiction check: captured entry matched existing governance entries:");
|
|
2133
|
-
for (const w of contradictionWarnings) {
|
|
2134
|
-
lines.push(`- ${w.name} (${w.collection}, ${w.entryId}) \u2014 has 'governs' relation to ${w.governsCount} entries`);
|
|
2135
|
-
}
|
|
2136
|
-
lines.push("Review the matched governance entries and reconcile any actual conflict.");
|
|
2137
|
-
}
|
|
2138
2012
|
if (entryWarnings.length > 0) {
|
|
2139
2013
|
lines.push("");
|
|
2140
2014
|
lines.push("## Validation Warnings");
|
|
@@ -2248,46 +2122,6 @@ Use \`entries action=get\` to inspect the existing entry, or \`entries action=up
|
|
|
2248
2122
|
};
|
|
2249
2123
|
return toolResult;
|
|
2250
2124
|
}
|
|
2251
|
-
async function runContradictionCheck(name, description, excludeEntryId, excludeDocId) {
|
|
2252
|
-
const warnings = [];
|
|
2253
|
-
try {
|
|
2254
|
-
const keyTerms = tokenizeText(`${name} ${description}`).filter((w) => w.length >= 4 && !STOP_WORDS.has(w)).slice(0, 8);
|
|
2255
|
-
if (keyTerms.length === 0) return warnings;
|
|
2256
|
-
const searchQuery = keyTerms.slice(0, 5).join(" ");
|
|
2257
|
-
const [govResults, archResults] = await Promise.all([
|
|
2258
|
-
kernelQuery("chain.searchEntries", { query: searchQuery, collectionSlug: "business-rules" }),
|
|
2259
|
-
kernelQuery("chain.searchEntries", { query: searchQuery, collectionSlug: "architecture" })
|
|
2260
|
-
]);
|
|
2261
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2262
|
-
const allGov = [...govResults ?? [], ...archResults ?? []].filter((entry) => {
|
|
2263
|
-
const id = entry.entryId ?? entry._id;
|
|
2264
|
-
if (!id || excludeEntryId && entry.entryId === excludeEntryId || excludeDocId && entry._id === excludeDocId || seen.has(id)) return false;
|
|
2265
|
-
seen.add(id);
|
|
2266
|
-
return true;
|
|
2267
|
-
}).slice(0, 5);
|
|
2268
|
-
for (const entry of allGov) {
|
|
2269
|
-
const entryTokens = new Set(tokenizeText(`${entry.name} ${readEntryBody(entry.data, "description") ?? ""}`));
|
|
2270
|
-
const matched = keyTerms.filter((t) => entryTokens.has(t));
|
|
2271
|
-
if (matched.length < 3) continue;
|
|
2272
|
-
let governsCount = 0;
|
|
2273
|
-
try {
|
|
2274
|
-
const relations = await kernelQuery("chain.listEntryRelations", {
|
|
2275
|
-
entryId: entry.entryId
|
|
2276
|
-
});
|
|
2277
|
-
governsCount = (relations ?? []).filter((r) => r.type === "governs").length;
|
|
2278
|
-
} catch {
|
|
2279
|
-
}
|
|
2280
|
-
warnings.push({
|
|
2281
|
-
entryId: entry.entryId ?? "",
|
|
2282
|
-
name: entry.name,
|
|
2283
|
-
collection: entry.collectionSlug ?? "",
|
|
2284
|
-
governsCount
|
|
2285
|
-
});
|
|
2286
|
-
}
|
|
2287
|
-
} catch {
|
|
2288
|
-
}
|
|
2289
|
-
return warnings;
|
|
2290
|
-
}
|
|
2291
2125
|
|
|
2292
2126
|
// src/tools/conflict-preflight.ts
|
|
2293
2127
|
async function runConflictPreflight(name, description, collectionHint) {
|
|
@@ -2297,19 +2131,10 @@ async function runConflictPreflight(name, description, collectionHint) {
|
|
|
2297
2131
|
description,
|
|
2298
2132
|
...collectionHint ? { collectionHint } : {}
|
|
2299
2133
|
});
|
|
2300
|
-
return {
|
|
2301
|
-
source: "semantic",
|
|
2302
|
-
conflicts: conflicts ?? [],
|
|
2303
|
-
advisoryWarnings: []
|
|
2304
|
-
};
|
|
2134
|
+
return { conflicts: conflicts ?? [] };
|
|
2305
2135
|
} catch (err) {
|
|
2306
|
-
console.error("[conflict-preflight] Semantic conflict detection unavailable
|
|
2307
|
-
|
|
2308
|
-
return {
|
|
2309
|
-
source: "heuristic",
|
|
2310
|
-
conflicts: [],
|
|
2311
|
-
advisoryWarnings
|
|
2312
|
-
};
|
|
2136
|
+
console.error("[conflict-preflight] Semantic conflict detection unavailable:", err instanceof Error ? err.message : String(err));
|
|
2137
|
+
return { conflicts: [] };
|
|
2313
2138
|
}
|
|
2314
2139
|
}
|
|
2315
2140
|
|
|
@@ -2631,29 +2456,22 @@ async function handleCommitEntry({ entryId, preview, steeringOverrideReason, coh
|
|
|
2631
2456
|
descField,
|
|
2632
2457
|
entry.collectionSlug ?? entry.collection?.slug ?? entry.collection?.name
|
|
2633
2458
|
);
|
|
2634
|
-
const advisoryWarnings = preflight.
|
|
2635
|
-
kind: "semantic",
|
|
2459
|
+
const advisoryWarnings = preflight.conflicts.map((conflict) => ({
|
|
2636
2460
|
entryId: conflict.chainEntryId,
|
|
2637
2461
|
name: conflict.chainEntryName,
|
|
2638
2462
|
explanation: conflict.explanation
|
|
2639
|
-
})) : preflight.advisoryWarnings.map((warning) => ({
|
|
2640
|
-
kind: "heuristic",
|
|
2641
|
-
entryId: warning.entryId,
|
|
2642
|
-
name: warning.name,
|
|
2643
|
-
collection: warning.collection,
|
|
2644
|
-
governsCount: warning.governsCount
|
|
2645
2463
|
}));
|
|
2646
2464
|
if (advisoryWarnings.length > 0) {
|
|
2647
2465
|
await recordSessionActivity({ contradictionWarning: true });
|
|
2648
2466
|
}
|
|
2649
|
-
const conflictEvidence = preflight.
|
|
2467
|
+
const conflictEvidence = preflight.conflicts.map((c) => ({
|
|
2650
2468
|
chainEntryId: c.chainEntryId,
|
|
2651
2469
|
chainEntryName: c.chainEntryName,
|
|
2652
2470
|
...c.chainEntryDescription ? { chainEntryDescription: c.chainEntryDescription } : {},
|
|
2653
2471
|
type: c.type,
|
|
2654
2472
|
confidence: c.confidence,
|
|
2655
2473
|
explanation: c.explanation
|
|
2656
|
-
}))
|
|
2474
|
+
}));
|
|
2657
2475
|
const judgeWait = preview ? null : await settleVerdictBeforeAccept(
|
|
2658
2476
|
() => kernelMutation("quality.evaluateHeuristicAndSchedule", { entryId, context: "commit" }),
|
|
2659
2477
|
() => kernelQuery("quality.getLatestVerdictForEntry", { entryId })
|
|
@@ -2754,11 +2572,13 @@ No DB writes \u2014 call without \`preview:true\` to accept for real.` }],
|
|
|
2754
2572
|
}
|
|
2755
2573
|
if (advisoryWarnings.length > 0) {
|
|
2756
2574
|
lines.push("");
|
|
2757
|
-
lines.push(
|
|
2575
|
+
lines.push("\u26A0 Semantic conflict preflight: advisory conflict(s) found.");
|
|
2758
2576
|
for (const w of advisoryWarnings) {
|
|
2759
|
-
lines.push(
|
|
2577
|
+
lines.push(`- ${w.name} (${w.entryId}) \u2014 ${w.explanation}`);
|
|
2760
2578
|
}
|
|
2761
|
-
lines.push(
|
|
2579
|
+
lines.push(
|
|
2580
|
+
"Run context action=gather on the conflicting entries to review; use entries action=update to reconcile the two, or to mark this entry status='archived' if it's actually superseded."
|
|
2581
|
+
);
|
|
2762
2582
|
}
|
|
2763
2583
|
if (coachingResult?.verdict) {
|
|
2764
2584
|
try {
|
|
@@ -10866,17 +10686,17 @@ async function handleCommitConstellation(args) {
|
|
|
10866
10686
|
} catch {
|
|
10867
10687
|
}
|
|
10868
10688
|
const preflight = await runConflictPreflight(betName, betDesc, betCollectionHint);
|
|
10869
|
-
if (preflight.
|
|
10689
|
+
if (preflight.conflicts.length > 0) {
|
|
10870
10690
|
await recordSessionActivity({ contradictionWarning: true });
|
|
10871
10691
|
}
|
|
10872
|
-
const conflictEvidence = preflight.
|
|
10692
|
+
const conflictEvidence = preflight.conflicts.map((c) => ({
|
|
10873
10693
|
chainEntryId: c.chainEntryId,
|
|
10874
10694
|
chainEntryName: c.chainEntryName,
|
|
10875
10695
|
...c.chainEntryDescription ? { chainEntryDescription: c.chainEntryDescription } : {},
|
|
10876
10696
|
type: c.type,
|
|
10877
10697
|
confidence: c.confidence,
|
|
10878
10698
|
explanation: c.explanation
|
|
10879
|
-
}))
|
|
10699
|
+
}));
|
|
10880
10700
|
let envelope;
|
|
10881
10701
|
try {
|
|
10882
10702
|
envelope = await kernelCallEnvelope("agentKnowledge.facilitateEnvelope", {
|
|
@@ -10984,9 +10804,7 @@ No constellation entries were accepted.`
|
|
|
10984
10804
|
}
|
|
10985
10805
|
const result2 = envelope.data.result;
|
|
10986
10806
|
const suggestions = {
|
|
10987
|
-
|
|
10988
|
-
...preflight.source === "semantic" && preflight.conflicts.length > 0 ? { conflicts: preflight.conflicts } : {},
|
|
10989
|
-
...preflight.source === "heuristic" && preflight.advisoryWarnings.length > 0 ? { advisoryWarnings: preflight.advisoryWarnings } : {}
|
|
10807
|
+
...preflight.conflicts.length > 0 ? { conflicts: preflight.conflicts } : {}
|
|
10990
10808
|
};
|
|
10991
10809
|
const lines = [];
|
|
10992
10810
|
const hasIssues = (result2.failedIds?.length ?? 0) > 0 || (result2.conflictIds?.length ?? 0) > 0;
|
|
@@ -10996,20 +10814,12 @@ No constellation entries were accepted.`
|
|
|
10996
10814
|
`**${result2.committedIds?.length ?? 0} entries** accepted onto the Chain, **${result2.totalRelations} connections** preserved.`,
|
|
10997
10815
|
hasIssues ? `\`${betId}\` was partially accepted. Review conflicts/failed entries below before considering the constellation complete.` : `\`${betId}\` and its full constellation are now source of truth.`
|
|
10998
10816
|
);
|
|
10999
|
-
if (preflight.
|
|
10817
|
+
if (preflight.conflicts.length > 0) {
|
|
11000
10818
|
lines.push(
|
|
11001
10819
|
"",
|
|
11002
10820
|
`\u26A0 **Semantic conflict preflight** (advisory):`,
|
|
11003
10821
|
...preflight.conflicts.map((c) => `- \`${c.chainEntryId}\` ${c.chainEntryName}: ${c.explanation}`)
|
|
11004
10822
|
);
|
|
11005
|
-
} else if (preflight.source === "heuristic" && preflight.advisoryWarnings.length > 0) {
|
|
11006
|
-
lines.push(
|
|
11007
|
-
"",
|
|
11008
|
-
`\u26A0 **Contradiction warnings** (advisory):`,
|
|
11009
|
-
...preflight.advisoryWarnings.map(
|
|
11010
|
-
(w) => `- \`${w.entryId}\` ${w.name} [${w.collection}] (${w.governsCount} governs relation${w.governsCount === 1 ? "" : "s"})`
|
|
11011
|
-
)
|
|
11012
|
-
);
|
|
11013
10823
|
}
|
|
11014
10824
|
if ((result2.committedIds?.length ?? 0) > 0) {
|
|
11015
10825
|
lines.push("", `**Accepted:** ${result2.committedIds.join(", ")}`);
|
|
@@ -13076,9 +12886,8 @@ async function buildOrientationResourceText(kernelQuery3, agentSessionId) {
|
|
|
13076
12886
|
|
|
13077
12887
|
// src/resources/terminologyResource.ts
|
|
13078
12888
|
async function buildTerminologyResourceText() {
|
|
13079
|
-
const [glossaryResult
|
|
13080
|
-
kernelQuery("chain.listEntries", { collectionSlug: "glossary" })
|
|
13081
|
-
kernelQuery("chain.listEntries", { collectionSlug: "standards" })
|
|
12889
|
+
const [glossaryResult] = await Promise.allSettled([
|
|
12890
|
+
kernelQuery("chain.listEntries", { collectionSlug: "glossary" })
|
|
13082
12891
|
]);
|
|
13083
12892
|
const lines = ["# Product Brain \u2014 Terminology"];
|
|
13084
12893
|
const platformTerms = PLATFORM_GLOSSARY_TERMS.map((t) => `- **${t.name}** (platform term): ${t.definition}`).join("\n");
|
|
@@ -13097,19 +12906,6 @@ ${platformTerms}
|
|
|
13097
12906
|
|
|
13098
12907
|
Could not load this team's terms \u2014 use \`entries action=list collection=glossary\` to browse manually.`);
|
|
13099
12908
|
}
|
|
13100
|
-
if (standardsResult.status === "fulfilled") {
|
|
13101
|
-
const standards = standardsResult.value ?? [];
|
|
13102
|
-
if (standards.length > 0) {
|
|
13103
|
-
const stds = standards.map((s) => `- **${s.name}** (${s.entryId ?? "\u2014"}) [${s.status}]: ${readEntryBody(s.data, "description") ?? ""}`).join("\n");
|
|
13104
|
-
lines.push(`## Standards (${standards.length} entries)
|
|
13105
|
-
|
|
13106
|
-
${stds}`);
|
|
13107
|
-
} else {
|
|
13108
|
-
lines.push("## Standards\n\nNo standards yet. Use `capture` with collection `standards` to add standards.");
|
|
13109
|
-
}
|
|
13110
|
-
} else {
|
|
13111
|
-
lines.push("## Standards\n\nCould not load standards \u2014 use `entries action=list collection=standards` to browse manually.");
|
|
13112
|
-
}
|
|
13113
12909
|
return lines.join("\n\n---\n\n");
|
|
13114
12910
|
}
|
|
13115
12911
|
|
|
@@ -13741,4 +13537,4 @@ export {
|
|
|
13741
13537
|
createProductBrainServer,
|
|
13742
13538
|
initFeatureFlags
|
|
13743
13539
|
};
|
|
13744
|
-
//# sourceMappingURL=chunk-
|
|
13540
|
+
//# sourceMappingURL=chunk-BZGJXC6D.js.map
|