@contractspec/bundle.library 3.8.2 → 3.8.5
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/.turbo/turbo-build.log +130 -116
- package/CHANGELOG.md +80 -0
- package/dist/application/index.js +806 -131
- package/dist/application/mcp/cliMcp.js +21 -2
- package/dist/application/mcp/common.js +21 -2
- package/dist/application/mcp/common.test.d.ts +1 -0
- package/dist/application/mcp/contractsMcp.js +21 -2
- package/dist/application/mcp/docsMcp.catalog.d.ts +2 -0
- package/dist/application/mcp/docsMcp.catalog.js +382 -0
- package/dist/application/mcp/docsMcp.d.ts +5 -1
- package/dist/application/mcp/docsMcp.data.d.ts +85 -0
- package/dist/application/mcp/docsMcp.data.js +148 -0
- package/dist/application/mcp/docsMcp.js +776 -101
- package/dist/application/mcp/docsMcp.prompts.d.ts +3 -0
- package/dist/application/mcp/docsMcp.prompts.js +522 -0
- package/dist/application/mcp/docsMcp.reference.d.ts +24 -0
- package/dist/application/mcp/docsMcp.reference.js +236 -0
- package/dist/application/mcp/docsMcp.resources.d.ts +3 -0
- package/dist/application/mcp/docsMcp.resources.js +520 -0
- package/dist/application/mcp/docsMcp.test.d.ts +1 -0
- package/dist/application/mcp/docsMcp.tools.d.ts +3 -0
- package/dist/application/mcp/docsMcp.tools.js +519 -0
- package/dist/application/mcp/index.js +806 -131
- package/dist/application/mcp/internalMcp.js +21 -2
- package/dist/application/mcp/normalizeMcpRequest.d.ts +1 -0
- package/dist/application/mcp/normalizeMcpRequest.js +22 -0
- package/dist/application/mcp/providerRankingMcp.js +21 -2
- package/dist/components/docs/generated/docs-index.generated.d.ts +6 -6
- package/dist/components/docs/index.js +23 -24
- package/dist/components/docs/libraries/LibrariesAiAgentPage.js +22 -22
- package/dist/components/docs/libraries/LibrariesSupportBotPage.js +1 -2
- package/dist/components/docs/libraries/index.js +23 -24
- package/dist/components/templates/engine/index.d.ts +1 -1
- package/dist/components/templates/engine/index.js +1 -1
- package/dist/features/index.js +15 -15
- package/dist/index.js +194 -195
- package/dist/node/application/index.js +806 -131
- package/dist/node/application/mcp/cliMcp.js +21 -2
- package/dist/node/application/mcp/common.js +21 -2
- package/dist/node/application/mcp/contractsMcp.js +21 -2
- package/dist/node/application/mcp/docsMcp.catalog.js +381 -0
- package/dist/node/application/mcp/docsMcp.data.js +147 -0
- package/dist/node/application/mcp/docsMcp.js +776 -101
- package/dist/node/application/mcp/docsMcp.prompts.js +521 -0
- package/dist/node/application/mcp/docsMcp.reference.js +235 -0
- package/dist/node/application/mcp/docsMcp.resources.js +519 -0
- package/dist/node/application/mcp/docsMcp.tools.js +518 -0
- package/dist/node/application/mcp/index.js +806 -131
- package/dist/node/application/mcp/internalMcp.js +21 -2
- package/dist/node/application/mcp/normalizeMcpRequest.js +21 -0
- package/dist/node/application/mcp/providerRankingMcp.js +21 -2
- package/dist/node/components/docs/index.js +23 -24
- package/dist/node/components/docs/libraries/LibrariesAiAgentPage.js +22 -22
- package/dist/node/components/docs/libraries/LibrariesSupportBotPage.js +1 -2
- package/dist/node/components/docs/libraries/index.js +23 -24
- package/dist/node/components/templates/engine/index.js +1 -1
- package/dist/node/features/index.js +15 -15
- package/dist/node/index.js +194 -195
- package/dist/node/presentation/features/hooks/index.js +12 -12
- package/dist/node/presentation/features/hooks/useContractsRegistry.js +12 -12
- package/dist/node/presentation/features/index.js +12 -12
- package/dist/node/presentation/features/organisms/FeatureDataViewsList.js +12 -12
- package/dist/node/presentation/features/organisms/FeatureEventsList.js +12 -12
- package/dist/node/presentation/features/organisms/FeatureFormsList.js +12 -12
- package/dist/node/presentation/features/organisms/FeaturePresentationsList.js +12 -12
- package/dist/node/presentation/features/organisms/index.js +12 -12
- package/dist/node/presentation/features/templates/FeatureDataViewsTemplate/FeatureDataViewsTemplate.js +12 -12
- package/dist/node/presentation/features/templates/FeatureDataViewsTemplate/index.js +12 -12
- package/dist/node/presentation/features/templates/FeatureEventsTemplate/FeatureEventsTemplate.js +12 -12
- package/dist/node/presentation/features/templates/FeatureEventsTemplate/index.js +12 -12
- package/dist/node/presentation/features/templates/FeatureFormsTemplate/FeatureFormsTemplate.js +12 -12
- package/dist/node/presentation/features/templates/FeatureFormsTemplate/index.js +12 -12
- package/dist/node/presentation/features/templates/FeaturePresentationsTemplate/FeaturePresentationsTemplate.js +12 -12
- package/dist/node/presentation/features/templates/FeaturePresentationsTemplate/index.js +12 -12
- package/dist/presentation/features/hooks/index.js +12 -12
- package/dist/presentation/features/hooks/useContractsRegistry.js +12 -12
- package/dist/presentation/features/index.js +12 -12
- package/dist/presentation/features/organisms/FeatureDataViewsList.js +12 -12
- package/dist/presentation/features/organisms/FeatureEventsList.js +12 -12
- package/dist/presentation/features/organisms/FeatureFormsList.js +12 -12
- package/dist/presentation/features/organisms/FeaturePresentationsList.js +12 -12
- package/dist/presentation/features/organisms/index.js +12 -12
- package/dist/presentation/features/templates/FeatureDataViewsTemplate/FeatureDataViewsTemplate.js +12 -12
- package/dist/presentation/features/templates/FeatureDataViewsTemplate/index.js +12 -12
- package/dist/presentation/features/templates/FeatureEventsTemplate/FeatureEventsTemplate.js +12 -12
- package/dist/presentation/features/templates/FeatureEventsTemplate/index.js +12 -12
- package/dist/presentation/features/templates/FeatureFormsTemplate/FeatureFormsTemplate.js +12 -12
- package/dist/presentation/features/templates/FeatureFormsTemplate/index.js +12 -12
- package/dist/presentation/features/templates/FeaturePresentationsTemplate/FeaturePresentationsTemplate.js +12 -12
- package/dist/presentation/features/templates/FeaturePresentationsTemplate/index.js +12 -12
- package/package.json +108 -23
- package/src/application/mcp/common.test.ts +64 -0
- package/src/application/mcp/common.ts +5 -2
- package/src/application/mcp/docsMcp.catalog.ts +2 -0
- package/src/application/mcp/docsMcp.data.ts +196 -0
- package/src/application/mcp/docsMcp.prompts.ts +165 -0
- package/src/application/mcp/docsMcp.reference.ts +152 -0
- package/src/application/mcp/docsMcp.resources.ts +194 -0
- package/src/application/mcp/docsMcp.test.ts +148 -0
- package/src/application/mcp/docsMcp.tools.ts +183 -0
- package/src/application/mcp/docsMcp.ts +13 -177
- package/src/application/mcp/normalizeMcpRequest.ts +30 -0
- package/src/components/docs/generated/docs-index._common.json +1 -1
- package/src/components/docs/generated/docs-index.ai-chat-assistant.json +8 -0
- package/src/components/docs/generated/docs-index.artisan-knowledge-product.json +18 -0
- package/src/components/docs/generated/docs-index.artisan-payments-stripe.json +34 -0
- package/src/components/docs/generated/docs-index.data-grid-showcase.json +18 -0
- package/src/components/docs/generated/docs-index.generated.ts +6 -6
- package/src/components/docs/generated/docs-index.harness-lab.json +10 -0
- package/src/components/docs/generated/docs-index.locale-jurisdiction-gate.json +8 -0
- package/src/components/docs/generated/docs-index.manifest.json +50 -5
- package/src/components/docs/generated/docs-index.messaging-agent-actions.json +18 -0
- package/src/components/docs/generated/docs-index.mobile-demo-tasks.json +34 -0
- package/src/components/docs/generated/docs-index.opencode-cli.json +2 -2
- package/src/components/docs/generated/docs-index.platform-control-plane.json +250 -0
- package/src/components/docs/generated/docs-index.platform-harness.json +178 -0
- package/src/components/docs/generated/docs-index.platform-integrations.json +22 -14
- package/src/components/docs/generated/docs-index.visualization-showcase.json +18 -0
- package/src/components/docs/libraries/LibrariesAiAgentPage.tsx +20 -17
- package/src/components/docs/libraries/LibrariesSupportBotPage.tsx +1 -2
- package/src/components/templates/engine/index.ts +2 -2
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/application/mcp/docsMcp.data.ts
|
|
3
|
+
import { defaultDocRegistry } from "@contractspec/lib.contracts-spec/docs";
|
|
4
|
+
var DEFAULT_LIMIT = 20;
|
|
5
|
+
var MAX_LIMIT = 100;
|
|
6
|
+
function normalizeText(value) {
|
|
7
|
+
return value?.trim().toLowerCase() ?? "";
|
|
8
|
+
}
|
|
9
|
+
function normalizeRoute(route) {
|
|
10
|
+
const decoded = decodeURIComponent(route).trim();
|
|
11
|
+
if (!decoded)
|
|
12
|
+
return "/";
|
|
13
|
+
return decoded.startsWith("/") ? decoded : `/${decoded}`;
|
|
14
|
+
}
|
|
15
|
+
function normalizeTags(value) {
|
|
16
|
+
const tags = Array.isArray(value) ? value : value ? [value] : [];
|
|
17
|
+
return tags.map((tag) => normalizeText(tag)).filter(Boolean);
|
|
18
|
+
}
|
|
19
|
+
function clampLimit(limit) {
|
|
20
|
+
if (!limit || Number.isNaN(limit))
|
|
21
|
+
return DEFAULT_LIMIT;
|
|
22
|
+
return Math.min(Math.max(limit, 1), MAX_LIMIT);
|
|
23
|
+
}
|
|
24
|
+
function clampOffset(offset) {
|
|
25
|
+
if (!offset || Number.isNaN(offset))
|
|
26
|
+
return 0;
|
|
27
|
+
return Math.max(offset, 0);
|
|
28
|
+
}
|
|
29
|
+
function toDocSummary({ block, route }) {
|
|
30
|
+
return {
|
|
31
|
+
id: block.id,
|
|
32
|
+
title: block.title,
|
|
33
|
+
summary: block.summary ?? "",
|
|
34
|
+
route,
|
|
35
|
+
visibility: block.visibility ?? "public",
|
|
36
|
+
kind: block.kind ?? "reference",
|
|
37
|
+
version: block.version ?? "1.0.0",
|
|
38
|
+
tags: block.tags ?? []
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function scoreDoc(route, query) {
|
|
42
|
+
if (!query)
|
|
43
|
+
return 1;
|
|
44
|
+
const tokens = query.split(/\s+/).filter(Boolean);
|
|
45
|
+
const title = normalizeText(route.block.title);
|
|
46
|
+
const id = normalizeText(route.block.id);
|
|
47
|
+
const summary = normalizeText(route.block.summary);
|
|
48
|
+
const body = normalizeText(route.block.body);
|
|
49
|
+
const path = normalizeText(route.route);
|
|
50
|
+
const tags = (route.block.tags ?? []).map((tag) => normalizeText(tag));
|
|
51
|
+
const haystack = [title, id, summary, body, path, ...tags].join(" ");
|
|
52
|
+
if (tokens.some((token) => !haystack.includes(token)))
|
|
53
|
+
return 0;
|
|
54
|
+
let score = 0;
|
|
55
|
+
for (const token of tokens) {
|
|
56
|
+
if (id.includes(token))
|
|
57
|
+
score += 8;
|
|
58
|
+
if (title.includes(token))
|
|
59
|
+
score += 7;
|
|
60
|
+
if (tags.some((tag) => tag.includes(token)))
|
|
61
|
+
score += 5;
|
|
62
|
+
if (summary.includes(token))
|
|
63
|
+
score += 4;
|
|
64
|
+
if (path.includes(token))
|
|
65
|
+
score += 3;
|
|
66
|
+
if (body.includes(token))
|
|
67
|
+
score += 2;
|
|
68
|
+
}
|
|
69
|
+
return score;
|
|
70
|
+
}
|
|
71
|
+
function searchDocs(routes, args) {
|
|
72
|
+
const query = normalizeText(typeof args.query === "string" ? args.query : undefined);
|
|
73
|
+
const tags = normalizeTags(args.tag);
|
|
74
|
+
const visibility = normalizeText(typeof args.visibility === "string" ? args.visibility : undefined);
|
|
75
|
+
const kind = normalizeText(typeof args.kind === "string" ? args.kind : undefined);
|
|
76
|
+
const limit = clampLimit(typeof args.limit === "number" ? args.limit : undefined);
|
|
77
|
+
const offset = clampOffset(typeof args.offset === "number" ? args.offset : undefined);
|
|
78
|
+
const ranked = routes.map((route) => ({
|
|
79
|
+
doc: toDocSummary(route),
|
|
80
|
+
score: scoreDoc(route, query)
|
|
81
|
+
})).filter(({ doc, score }) => {
|
|
82
|
+
const matchesQuery = query ? score > 0 : true;
|
|
83
|
+
const matchesTags = tags.length ? tags.every((tag) => doc.tags.some((docTag) => normalizeText(docTag).includes(tag))) : true;
|
|
84
|
+
const matchesVisibility = visibility ? normalizeText(doc.visibility) === visibility : true;
|
|
85
|
+
const matchesKind = kind ? normalizeText(doc.kind) === kind : true;
|
|
86
|
+
return matchesQuery && matchesTags && matchesVisibility && matchesKind;
|
|
87
|
+
}).sort((left, right) => {
|
|
88
|
+
if (right.score !== left.score)
|
|
89
|
+
return right.score - left.score;
|
|
90
|
+
return left.doc.title.localeCompare(right.doc.title);
|
|
91
|
+
});
|
|
92
|
+
const docs = ranked.slice(offset, offset + limit).map(({ doc }) => doc);
|
|
93
|
+
const nextOffset = offset + docs.length < ranked.length ? offset + docs.length : undefined;
|
|
94
|
+
return {
|
|
95
|
+
docs,
|
|
96
|
+
items: docs,
|
|
97
|
+
total: ranked.length,
|
|
98
|
+
...nextOffset != null ? { nextOffset } : {}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function getDocById(id) {
|
|
102
|
+
const normalizedId = decodeURIComponent(id);
|
|
103
|
+
const found = defaultDocRegistry.get(normalizedId);
|
|
104
|
+
if (!found)
|
|
105
|
+
return;
|
|
106
|
+
return {
|
|
107
|
+
doc: toDocSummary(found),
|
|
108
|
+
content: String(found.block.body ?? "")
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function getDocByRoute(routes, routePath) {
|
|
112
|
+
const normalizedPath = normalizeRoute(routePath);
|
|
113
|
+
const found = routes.find((route) => normalizeRoute(route.route) === normalizedPath);
|
|
114
|
+
if (!found)
|
|
115
|
+
return;
|
|
116
|
+
return {
|
|
117
|
+
doc: toDocSummary(found),
|
|
118
|
+
content: String(found.block.body ?? "")
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function listDocFacets(routes) {
|
|
122
|
+
const tags = new Map;
|
|
123
|
+
const kinds = new Map;
|
|
124
|
+
const visibilities = new Map;
|
|
125
|
+
for (const route of routes) {
|
|
126
|
+
const kind = route.block.kind ?? "reference";
|
|
127
|
+
const visibility = route.block.visibility ?? "public";
|
|
128
|
+
kinds.set(kind, (kinds.get(kind) ?? 0) + 1);
|
|
129
|
+
visibilities.set(visibility, (visibilities.get(visibility) ?? 0) + 1);
|
|
130
|
+
for (const tag of route.block.tags ?? []) {
|
|
131
|
+
tags.set(tag, (tags.get(tag) ?? 0) + 1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const toEntries = (values, key) => [...values.entries()].sort((left, right) => right[1] - left[1] || left[0].localeCompare(right[0])).map(([value, count]) => ({ [key]: value, count }));
|
|
135
|
+
return {
|
|
136
|
+
totalDocs: routes.length,
|
|
137
|
+
tags: toEntries(tags, "tag"),
|
|
138
|
+
kinds: toEntries(kinds, "kind"),
|
|
139
|
+
visibilities: toEntries(visibilities, "visibility")
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export {
|
|
143
|
+
toDocSummary,
|
|
144
|
+
searchDocs,
|
|
145
|
+
listDocFacets,
|
|
146
|
+
getDocByRoute,
|
|
147
|
+
getDocById
|
|
148
|
+
};
|