@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.
Files changed (121) hide show
  1. package/.turbo/turbo-build.log +130 -116
  2. package/CHANGELOG.md +80 -0
  3. package/dist/application/index.js +806 -131
  4. package/dist/application/mcp/cliMcp.js +21 -2
  5. package/dist/application/mcp/common.js +21 -2
  6. package/dist/application/mcp/common.test.d.ts +1 -0
  7. package/dist/application/mcp/contractsMcp.js +21 -2
  8. package/dist/application/mcp/docsMcp.catalog.d.ts +2 -0
  9. package/dist/application/mcp/docsMcp.catalog.js +382 -0
  10. package/dist/application/mcp/docsMcp.d.ts +5 -1
  11. package/dist/application/mcp/docsMcp.data.d.ts +85 -0
  12. package/dist/application/mcp/docsMcp.data.js +148 -0
  13. package/dist/application/mcp/docsMcp.js +776 -101
  14. package/dist/application/mcp/docsMcp.prompts.d.ts +3 -0
  15. package/dist/application/mcp/docsMcp.prompts.js +522 -0
  16. package/dist/application/mcp/docsMcp.reference.d.ts +24 -0
  17. package/dist/application/mcp/docsMcp.reference.js +236 -0
  18. package/dist/application/mcp/docsMcp.resources.d.ts +3 -0
  19. package/dist/application/mcp/docsMcp.resources.js +520 -0
  20. package/dist/application/mcp/docsMcp.test.d.ts +1 -0
  21. package/dist/application/mcp/docsMcp.tools.d.ts +3 -0
  22. package/dist/application/mcp/docsMcp.tools.js +519 -0
  23. package/dist/application/mcp/index.js +806 -131
  24. package/dist/application/mcp/internalMcp.js +21 -2
  25. package/dist/application/mcp/normalizeMcpRequest.d.ts +1 -0
  26. package/dist/application/mcp/normalizeMcpRequest.js +22 -0
  27. package/dist/application/mcp/providerRankingMcp.js +21 -2
  28. package/dist/components/docs/generated/docs-index.generated.d.ts +6 -6
  29. package/dist/components/docs/index.js +23 -24
  30. package/dist/components/docs/libraries/LibrariesAiAgentPage.js +22 -22
  31. package/dist/components/docs/libraries/LibrariesSupportBotPage.js +1 -2
  32. package/dist/components/docs/libraries/index.js +23 -24
  33. package/dist/components/templates/engine/index.d.ts +1 -1
  34. package/dist/components/templates/engine/index.js +1 -1
  35. package/dist/features/index.js +15 -15
  36. package/dist/index.js +194 -195
  37. package/dist/node/application/index.js +806 -131
  38. package/dist/node/application/mcp/cliMcp.js +21 -2
  39. package/dist/node/application/mcp/common.js +21 -2
  40. package/dist/node/application/mcp/contractsMcp.js +21 -2
  41. package/dist/node/application/mcp/docsMcp.catalog.js +381 -0
  42. package/dist/node/application/mcp/docsMcp.data.js +147 -0
  43. package/dist/node/application/mcp/docsMcp.js +776 -101
  44. package/dist/node/application/mcp/docsMcp.prompts.js +521 -0
  45. package/dist/node/application/mcp/docsMcp.reference.js +235 -0
  46. package/dist/node/application/mcp/docsMcp.resources.js +519 -0
  47. package/dist/node/application/mcp/docsMcp.tools.js +518 -0
  48. package/dist/node/application/mcp/index.js +806 -131
  49. package/dist/node/application/mcp/internalMcp.js +21 -2
  50. package/dist/node/application/mcp/normalizeMcpRequest.js +21 -0
  51. package/dist/node/application/mcp/providerRankingMcp.js +21 -2
  52. package/dist/node/components/docs/index.js +23 -24
  53. package/dist/node/components/docs/libraries/LibrariesAiAgentPage.js +22 -22
  54. package/dist/node/components/docs/libraries/LibrariesSupportBotPage.js +1 -2
  55. package/dist/node/components/docs/libraries/index.js +23 -24
  56. package/dist/node/components/templates/engine/index.js +1 -1
  57. package/dist/node/features/index.js +15 -15
  58. package/dist/node/index.js +194 -195
  59. package/dist/node/presentation/features/hooks/index.js +12 -12
  60. package/dist/node/presentation/features/hooks/useContractsRegistry.js +12 -12
  61. package/dist/node/presentation/features/index.js +12 -12
  62. package/dist/node/presentation/features/organisms/FeatureDataViewsList.js +12 -12
  63. package/dist/node/presentation/features/organisms/FeatureEventsList.js +12 -12
  64. package/dist/node/presentation/features/organisms/FeatureFormsList.js +12 -12
  65. package/dist/node/presentation/features/organisms/FeaturePresentationsList.js +12 -12
  66. package/dist/node/presentation/features/organisms/index.js +12 -12
  67. package/dist/node/presentation/features/templates/FeatureDataViewsTemplate/FeatureDataViewsTemplate.js +12 -12
  68. package/dist/node/presentation/features/templates/FeatureDataViewsTemplate/index.js +12 -12
  69. package/dist/node/presentation/features/templates/FeatureEventsTemplate/FeatureEventsTemplate.js +12 -12
  70. package/dist/node/presentation/features/templates/FeatureEventsTemplate/index.js +12 -12
  71. package/dist/node/presentation/features/templates/FeatureFormsTemplate/FeatureFormsTemplate.js +12 -12
  72. package/dist/node/presentation/features/templates/FeatureFormsTemplate/index.js +12 -12
  73. package/dist/node/presentation/features/templates/FeaturePresentationsTemplate/FeaturePresentationsTemplate.js +12 -12
  74. package/dist/node/presentation/features/templates/FeaturePresentationsTemplate/index.js +12 -12
  75. package/dist/presentation/features/hooks/index.js +12 -12
  76. package/dist/presentation/features/hooks/useContractsRegistry.js +12 -12
  77. package/dist/presentation/features/index.js +12 -12
  78. package/dist/presentation/features/organisms/FeatureDataViewsList.js +12 -12
  79. package/dist/presentation/features/organisms/FeatureEventsList.js +12 -12
  80. package/dist/presentation/features/organisms/FeatureFormsList.js +12 -12
  81. package/dist/presentation/features/organisms/FeaturePresentationsList.js +12 -12
  82. package/dist/presentation/features/organisms/index.js +12 -12
  83. package/dist/presentation/features/templates/FeatureDataViewsTemplate/FeatureDataViewsTemplate.js +12 -12
  84. package/dist/presentation/features/templates/FeatureDataViewsTemplate/index.js +12 -12
  85. package/dist/presentation/features/templates/FeatureEventsTemplate/FeatureEventsTemplate.js +12 -12
  86. package/dist/presentation/features/templates/FeatureEventsTemplate/index.js +12 -12
  87. package/dist/presentation/features/templates/FeatureFormsTemplate/FeatureFormsTemplate.js +12 -12
  88. package/dist/presentation/features/templates/FeatureFormsTemplate/index.js +12 -12
  89. package/dist/presentation/features/templates/FeaturePresentationsTemplate/FeaturePresentationsTemplate.js +12 -12
  90. package/dist/presentation/features/templates/FeaturePresentationsTemplate/index.js +12 -12
  91. package/package.json +108 -23
  92. package/src/application/mcp/common.test.ts +64 -0
  93. package/src/application/mcp/common.ts +5 -2
  94. package/src/application/mcp/docsMcp.catalog.ts +2 -0
  95. package/src/application/mcp/docsMcp.data.ts +196 -0
  96. package/src/application/mcp/docsMcp.prompts.ts +165 -0
  97. package/src/application/mcp/docsMcp.reference.ts +152 -0
  98. package/src/application/mcp/docsMcp.resources.ts +194 -0
  99. package/src/application/mcp/docsMcp.test.ts +148 -0
  100. package/src/application/mcp/docsMcp.tools.ts +183 -0
  101. package/src/application/mcp/docsMcp.ts +13 -177
  102. package/src/application/mcp/normalizeMcpRequest.ts +30 -0
  103. package/src/components/docs/generated/docs-index._common.json +1 -1
  104. package/src/components/docs/generated/docs-index.ai-chat-assistant.json +8 -0
  105. package/src/components/docs/generated/docs-index.artisan-knowledge-product.json +18 -0
  106. package/src/components/docs/generated/docs-index.artisan-payments-stripe.json +34 -0
  107. package/src/components/docs/generated/docs-index.data-grid-showcase.json +18 -0
  108. package/src/components/docs/generated/docs-index.generated.ts +6 -6
  109. package/src/components/docs/generated/docs-index.harness-lab.json +10 -0
  110. package/src/components/docs/generated/docs-index.locale-jurisdiction-gate.json +8 -0
  111. package/src/components/docs/generated/docs-index.manifest.json +50 -5
  112. package/src/components/docs/generated/docs-index.messaging-agent-actions.json +18 -0
  113. package/src/components/docs/generated/docs-index.mobile-demo-tasks.json +34 -0
  114. package/src/components/docs/generated/docs-index.opencode-cli.json +2 -2
  115. package/src/components/docs/generated/docs-index.platform-control-plane.json +250 -0
  116. package/src/components/docs/generated/docs-index.platform-harness.json +178 -0
  117. package/src/components/docs/generated/docs-index.platform-integrations.json +22 -14
  118. package/src/components/docs/generated/docs-index.visualization-showcase.json +18 -0
  119. package/src/components/docs/libraries/LibrariesAiAgentPage.tsx +20 -17
  120. package/src/components/docs/libraries/LibrariesSupportBotPage.tsx +1 -2
  121. 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
+ };