@assistant-ui/mcp-docs-server 0.1.17 → 0.1.19
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/.docs/organized/code-examples/with-ag-ui.md +518 -234
- package/.docs/organized/code-examples/{with-ai-sdk-v5.md → with-ai-sdk-v6.md} +476 -189
- package/.docs/organized/code-examples/with-assistant-transport.md +503 -301
- package/.docs/organized/code-examples/with-cloud.md +524 -226
- package/.docs/organized/code-examples/with-custom-thread-list.md +433 -146
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +2241 -0
- package/.docs/organized/code-examples/with-external-store.md +517 -231
- package/.docs/organized/code-examples/with-ffmpeg.md +500 -220
- package/.docs/organized/code-examples/with-langgraph.md +630 -319
- package/.docs/organized/code-examples/with-parent-id-grouping.md +517 -231
- package/.docs/organized/code-examples/with-react-hook-form.md +517 -233
- package/.docs/organized/code-examples/with-react-router.md +2167 -0
- package/.docs/organized/code-examples/{store-example.md → with-store.md} +18 -22
- package/.docs/organized/code-examples/with-tanstack.md +23 -41
- package/.docs/raw/blog/2025-01-31-changelog/index.mdx +0 -2
- package/.docs/raw/docs/{about-assistantui.mdx → (docs)/about-assistantui.mdx} +2 -1
- package/.docs/raw/docs/{architecture.mdx → (docs)/architecture.mdx} +3 -2
- package/.docs/raw/docs/{cli.mdx → (docs)/cli.mdx} +1 -19
- package/.docs/raw/docs/{copilots → (docs)/copilots}/make-assistant-readable.mdx +1 -0
- package/.docs/raw/docs/{copilots → (docs)/copilots}/make-assistant-tool-ui.mdx +2 -1
- package/.docs/raw/docs/{copilots → (docs)/copilots}/make-assistant-tool.mdx +2 -1
- package/.docs/raw/docs/{copilots → (docs)/copilots}/model-context.mdx +1 -0
- package/.docs/raw/docs/{copilots → (docs)/copilots}/motivation.mdx +1 -0
- package/.docs/raw/docs/{copilots → (docs)/copilots}/use-assistant-instructions.mdx +1 -0
- package/.docs/raw/docs/{devtools.mdx → (docs)/devtools.mdx} +4 -4
- package/.docs/raw/docs/{guides/Attachments.mdx → (docs)/guides/attachments.mdx} +4 -5
- package/.docs/raw/docs/{guides/Branching.mdx → (docs)/guides/branching.mdx} +2 -1
- package/.docs/raw/docs/{guides → (docs)/guides}/context-api.mdx +1 -0
- package/.docs/raw/docs/(docs)/guides/dictation.mdx +370 -0
- package/.docs/raw/docs/{guides/Editing.mdx → (docs)/guides/editing.mdx} +1 -0
- package/.docs/raw/docs/{guides/Latex.mdx → (docs)/guides/latex.mdx} +1 -2
- package/.docs/raw/docs/{guides/Speech.mdx → (docs)/guides/speech.mdx} +9 -10
- package/.docs/raw/docs/{guides/ToolUI.mdx → (docs)/guides/tool-ui.mdx} +15 -14
- package/.docs/raw/docs/{guides/Tools.mdx → (docs)/guides/tools.mdx} +10 -7
- package/.docs/raw/docs/{getting-started.mdx → (docs)/index.mdx} +17 -22
- package/.docs/raw/docs/{mcp-docs-server.mdx → (docs)/mcp-docs-server.mdx} +1 -2
- package/.docs/raw/docs/{api-reference/context-providers/AssistantRuntimeProvider.mdx → (reference)/api-reference/context-providers/assistant-runtime-provider.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/context-providers/TextMessagePartProvider.mdx → (reference)/api-reference/context-providers/text-message-part-provider.mdx} +2 -1
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/integrations/react-data-stream.mdx +2 -1
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/integrations/react-hook-form.mdx +2 -1
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/integrations/vercel-ai-sdk.mdx +2 -2
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/overview.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +327 -0
- package/.docs/raw/docs/{api-reference/primitives/ActionBar.mdx → (reference)/api-reference/primitives/action-bar.mdx} +3 -1
- package/.docs/raw/docs/{api-reference/primitives/AssistantIf.mdx → (reference)/api-reference/primitives/assistant-if.mdx} +2 -2
- package/.docs/raw/docs/{api-reference/primitives/AssistantModal.mdx → (reference)/api-reference/primitives/assistant-modal.mdx} +3 -1
- package/.docs/raw/docs/{api-reference/primitives/Attachment.mdx → (reference)/api-reference/primitives/attachment.mdx} +3 -2
- package/.docs/raw/docs/{api-reference/primitives/BranchPicker.mdx → (reference)/api-reference/primitives/branch-picker.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/primitives/Composer.mdx → (reference)/api-reference/primitives/composer.mdx} +101 -2
- package/.docs/raw/docs/{api-reference → (reference)/api-reference}/primitives/composition.mdx +1 -0
- package/.docs/raw/docs/{api-reference/primitives/Error.mdx → (reference)/api-reference/primitives/error.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/primitives/MessagePart.mdx → (reference)/api-reference/primitives/message-part.mdx} +2 -2
- package/.docs/raw/docs/{api-reference/primitives/Message.mdx → (reference)/api-reference/primitives/message.mdx} +2 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +221 -0
- package/.docs/raw/docs/{api-reference/primitives/ThreadListItem.mdx → (reference)/api-reference/primitives/thread-list-item.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/primitives/ThreadList.mdx → (reference)/api-reference/primitives/thread-list.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/primitives/Thread.mdx → (reference)/api-reference/primitives/thread.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/AssistantRuntime.mdx → (reference)/api-reference/runtimes/assistant-runtime.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/AttachmentRuntime.mdx → (reference)/api-reference/runtimes/attachment-runtime.mdx} +3 -2
- package/.docs/raw/docs/{api-reference/runtimes/ComposerRuntime.mdx → (reference)/api-reference/runtimes/composer-runtime.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/MessagePartRuntime.mdx → (reference)/api-reference/runtimes/message-part-runtime.mdx} +3 -2
- package/.docs/raw/docs/{api-reference/runtimes/MessageRuntime.mdx → (reference)/api-reference/runtimes/message-runtime.mdx} +3 -2
- package/.docs/raw/docs/{api-reference/runtimes/ThreadListItemRuntime.mdx → (reference)/api-reference/runtimes/thread-list-item-runtime.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/ThreadListRuntime.mdx → (reference)/api-reference/runtimes/thread-list-runtime.mdx} +2 -1
- package/.docs/raw/docs/{api-reference/runtimes/ThreadRuntime.mdx → (reference)/api-reference/runtimes/thread-runtime.mdx} +3 -5
- package/.docs/raw/docs/{legacy/styled/AssistantModal.mdx → (reference)/legacy/styled/assistant-modal.mdx} +2 -3
- package/.docs/raw/docs/{legacy/styled/Decomposition.mdx → (reference)/legacy/styled/decomposition.mdx} +1 -0
- package/.docs/raw/docs/{legacy/styled/Markdown.mdx → (reference)/legacy/styled/markdown.mdx} +2 -4
- package/.docs/raw/docs/{legacy/styled/Scrollbar.mdx → (reference)/legacy/styled/scrollbar.mdx} +2 -1
- package/.docs/raw/docs/{legacy/styled/ThreadWidth.mdx → (reference)/legacy/styled/thread-width.mdx} +1 -0
- package/.docs/raw/docs/{legacy/styled/Thread.mdx → (reference)/legacy/styled/thread.mdx} +2 -3
- package/.docs/raw/docs/{migrations → (reference)/migrations}/deprecation-policy.mdx +1 -0
- package/.docs/raw/docs/{migrations → (reference)/migrations}/react-langgraph-v0-7.mdx +1 -2
- package/.docs/raw/docs/{migrations → (reference)/migrations}/v0-11.mdx +1 -0
- package/.docs/raw/docs/{migrations → (reference)/migrations}/v0-12.mdx +1 -0
- package/.docs/raw/docs/{react-compatibility.mdx → (reference)/react-compatibility.mdx} +2 -3
- package/.docs/raw/docs/cloud/authorization.mdx +1 -0
- package/.docs/raw/docs/cloud/overview.mdx +1 -0
- package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +2 -3
- package/.docs/raw/docs/cloud/persistence/langgraph.mdx +5 -7
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +9 -8
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +2 -3
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +7 -6
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +38 -3
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +6 -8
- package/.docs/raw/docs/runtimes/custom/local.mdx +43 -16
- package/.docs/raw/docs/runtimes/data-stream.mdx +32 -4
- package/.docs/raw/docs/runtimes/helicone.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +3 -3
- package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +1 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +2 -1
- package/.docs/raw/docs/runtimes/langserve.mdx +2 -2
- package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +4 -5
- package/.docs/raw/docs/runtimes/mastra/overview.mdx +1 -0
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +3 -4
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +2 -4
- package/.docs/raw/docs/ui/assistant-modal.mdx +163 -0
- package/.docs/raw/docs/ui/assistant-sidebar.mdx +90 -0
- package/.docs/raw/docs/ui/attachment.mdx +227 -0
- package/.docs/raw/docs/ui/{Markdown.mdx → markdown.mdx} +11 -6
- package/.docs/raw/docs/ui/{Mermaid.mdx → mermaid.mdx} +12 -5
- package/.docs/raw/docs/ui/{PartGrouping.mdx → part-grouping.mdx} +4 -6
- package/.docs/raw/docs/ui/reasoning.mdx +148 -0
- package/.docs/raw/docs/ui/{Scrollbar.mdx → scrollbar.mdx} +9 -7
- package/.docs/raw/docs/ui/sources.mdx +87 -0
- package/.docs/raw/docs/ui/{SyntaxHighlighting.mdx → syntax-highlighting.mdx} +9 -5
- package/.docs/raw/docs/ui/thread-list.mdx +275 -0
- package/.docs/raw/docs/ui/{Thread.mdx → thread.mdx} +5 -6
- package/.docs/raw/docs/ui/tool-fallback.mdx +112 -0
- package/.docs/raw/docs/ui/tool-group.mdx +214 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +14 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -0
- package/dist/prepare-docs/code-examples.d.ts +2 -0
- package/dist/prepare-docs/code-examples.d.ts.map +1 -0
- package/dist/prepare-docs/code-examples.js +129 -0
- package/dist/prepare-docs/code-examples.js.map +1 -0
- package/dist/prepare-docs/copy-raw.d.ts +2 -0
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -0
- package/dist/prepare-docs/copy-raw.js +50 -0
- package/dist/prepare-docs/copy-raw.js.map +1 -0
- package/dist/prepare-docs/prepare.d.ts +2 -0
- package/dist/prepare-docs/prepare.d.ts.map +1 -0
- package/dist/prepare-docs/prepare.js +18 -195
- package/dist/prepare-docs/prepare.js.map +1 -0
- package/dist/stdio.d.ts +3 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +4 -5
- package/dist/stdio.js.map +1 -0
- package/dist/tools/docs.d.ts +23 -0
- package/dist/tools/docs.d.ts.map +1 -0
- package/dist/tools/docs.js +168 -0
- package/dist/tools/docs.js.map +1 -0
- package/dist/tools/examples.d.ts +23 -0
- package/dist/tools/examples.d.ts.map +1 -0
- package/dist/tools/examples.js +95 -0
- package/dist/tools/examples.js.map +1 -0
- package/dist/tools/tests/test-setup.d.ts +4 -0
- package/dist/tools/tests/test-setup.d.ts.map +1 -0
- package/dist/tools/tests/test-setup.js +36 -0
- package/dist/tools/tests/test-setup.js.map +1 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +20 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mcp-format.d.ts +7 -0
- package/dist/utils/mcp-format.d.ts.map +1 -0
- package/dist/utils/mcp-format.js +11 -0
- package/dist/utils/mcp-format.js.map +1 -0
- package/dist/utils/mdx.d.ts +9 -0
- package/dist/utils/mdx.d.ts.map +1 -0
- package/dist/utils/mdx.js +27 -0
- package/dist/utils/mdx.js.map +1 -0
- package/dist/utils/paths.d.ts +8 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +84 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/security.d.ts +2 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +43 -0
- package/dist/utils/security.js.map +1 -0
- package/package.json +37 -19
- package/src/constants.ts +22 -0
- package/src/index.ts +51 -0
- package/src/prepare-docs/code-examples.ts +158 -0
- package/src/prepare-docs/copy-raw.ts +55 -0
- package/src/prepare-docs/prepare.ts +24 -0
- package/src/stdio.ts +7 -0
- package/src/tools/docs.ts +207 -0
- package/src/tools/examples.ts +107 -0
- package/src/tools/tests/docs.test.ts +124 -0
- package/src/tools/tests/examples.test.ts +94 -0
- package/src/tools/tests/integration.test.ts +46 -0
- package/src/tools/tests/json-parsing.test.ts +23 -0
- package/src/tools/tests/mcp-protocol.test.ts +133 -0
- package/src/tools/tests/path-traversal.test.ts +81 -0
- package/src/tools/tests/test-setup.ts +40 -0
- package/src/utils/logger.ts +20 -0
- package/src/utils/mcp-format.ts +12 -0
- package/src/utils/mdx.ts +39 -0
- package/src/utils/paths.ts +114 -0
- package/src/utils/security.ts +52 -0
- package/src/utils/tests/security.test.ts +119 -0
- package/.docs/raw/docs/index.mdx +0 -7
- package/.docs/raw/docs/ui/AssistantModal.mdx +0 -45
- package/.docs/raw/docs/ui/AssistantSidebar.mdx +0 -41
- package/.docs/raw/docs/ui/Attachment.mdx +0 -84
- package/.docs/raw/docs/ui/Reasoning.mdx +0 -152
- package/.docs/raw/docs/ui/ThreadList.mdx +0 -90
- package/.docs/raw/docs/ui/ToolFallback.mdx +0 -63
- package/.docs/raw/docs/ui/ToolGroup.mdx +0 -96
- package/dist/chunk-M2RKUM66.js +0 -38
- package/dist/chunk-NVNFQ5ZO.js +0 -423
- /package/.docs/raw/docs/{copilots → (docs)/copilots}/assistant-frame.mdx +0 -0
package/dist/index.js
CHANGED
|
@@ -1 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { docsTools } from "./tools/docs.js";
|
|
4
|
+
import { examplesTools } from "./tools/examples.js";
|
|
5
|
+
import { logger } from "./utils/logger.js";
|
|
6
|
+
import { PACKAGE_DIR } from "./constants.js";
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
const packageJson = JSON.parse(readFileSync(join(PACKAGE_DIR, "package.json"), "utf-8"));
|
|
10
|
+
export const server = new McpServer({
|
|
11
|
+
name: "assistant-ui-docs",
|
|
12
|
+
version: packageJson.version,
|
|
13
|
+
});
|
|
14
|
+
server.tool(docsTools.name, docsTools.description, docsTools.parameters, docsTools.execute);
|
|
15
|
+
server.tool(examplesTools.name, examplesTools.description, examplesTools.parameters, examplesTools.execute);
|
|
16
|
+
export async function runServer() {
|
|
17
|
+
try {
|
|
18
|
+
logger.info(`Starting assistant-ui MCP docs server v${packageJson.version}`);
|
|
19
|
+
const transport = new StdioServerTransport();
|
|
20
|
+
await server.connect(transport);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
logger.error("Failed to start MCP server", error);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
28
|
+
void runServer().catch((error) => {
|
|
29
|
+
console.error("Failed to start server:", error);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|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,SAAS,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;QAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpD,KAAK,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAC/B,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-examples.d.ts","sourceRoot":"","sources":["../../src/prepare-docs/code-examples.ts"],"names":[],"mappings":"AA2FA,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAkEzD"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { rm, mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join, relative, extname } from "node:path";
|
|
3
|
+
import { logger } from "../utils/logger.js";
|
|
4
|
+
import { ROOT_DIR, EXAMPLES_PATH } from "../constants.js";
|
|
5
|
+
const OUTPUT_DIR = join(ROOT_DIR, "packages/mcp-docs-server/.docs/organized/code-examples");
|
|
6
|
+
const MAX_LINES = 10000;
|
|
7
|
+
async function scanDirectory(dir, baseDir) {
|
|
8
|
+
const files = [];
|
|
9
|
+
try {
|
|
10
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
11
|
+
for (const entry of entries) {
|
|
12
|
+
const fullPath = join(dir, entry.name);
|
|
13
|
+
if (entry.isDirectory()) {
|
|
14
|
+
const skipDirs = [
|
|
15
|
+
"node_modules",
|
|
16
|
+
"dist",
|
|
17
|
+
"build",
|
|
18
|
+
".next",
|
|
19
|
+
".git",
|
|
20
|
+
".turbo",
|
|
21
|
+
];
|
|
22
|
+
if (!skipDirs.includes(entry.name)) {
|
|
23
|
+
const subFiles = await scanDirectory(fullPath, baseDir);
|
|
24
|
+
files.push(...subFiles);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else if (entry.isFile()) {
|
|
28
|
+
const includeExts = [
|
|
29
|
+
".ts",
|
|
30
|
+
".tsx",
|
|
31
|
+
".js",
|
|
32
|
+
".jsx",
|
|
33
|
+
".json",
|
|
34
|
+
".css",
|
|
35
|
+
".md",
|
|
36
|
+
".mdx",
|
|
37
|
+
];
|
|
38
|
+
const ext = extname(entry.name).toLowerCase();
|
|
39
|
+
if (includeExts.includes(ext) ||
|
|
40
|
+
entry.name === "package.json" ||
|
|
41
|
+
entry.name === "tsconfig.json") {
|
|
42
|
+
try {
|
|
43
|
+
const content = await readFile(fullPath, "utf-8");
|
|
44
|
+
const relativePath = relative(baseDir, fullPath);
|
|
45
|
+
files.push({ path: relativePath, content });
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
logger.warn(`Failed to read file: ${fullPath}`, error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
logger.error(`Failed to scan directory: ${dir}`, error);
|
|
56
|
+
}
|
|
57
|
+
return files;
|
|
58
|
+
}
|
|
59
|
+
function getFileType(filename) {
|
|
60
|
+
const ext = extname(filename).toLowerCase();
|
|
61
|
+
const extMap = {
|
|
62
|
+
".ts": "typescript",
|
|
63
|
+
".tsx": "tsx",
|
|
64
|
+
".js": "javascript",
|
|
65
|
+
".jsx": "jsx",
|
|
66
|
+
".json": "json",
|
|
67
|
+
".css": "css",
|
|
68
|
+
".md": "markdown",
|
|
69
|
+
".mdx": "mdx",
|
|
70
|
+
};
|
|
71
|
+
return extMap[ext] || "text";
|
|
72
|
+
}
|
|
73
|
+
export async function prepareCodeExamples() {
|
|
74
|
+
logger.info("Preparing code examples...");
|
|
75
|
+
try {
|
|
76
|
+
await rm(OUTPUT_DIR, { recursive: true, force: true });
|
|
77
|
+
await mkdir(OUTPUT_DIR, { recursive: true });
|
|
78
|
+
const exampleDirs = await readdir(EXAMPLES_PATH, { withFileTypes: true });
|
|
79
|
+
for (const dir of exampleDirs) {
|
|
80
|
+
if (dir.isDirectory() && !dir.name.startsWith(".")) {
|
|
81
|
+
const examplePath = join(EXAMPLES_PATH, dir.name);
|
|
82
|
+
logger.info(`Processing example: ${dir.name}`);
|
|
83
|
+
let description = "";
|
|
84
|
+
try {
|
|
85
|
+
const packageJsonPath = join(examplePath, "package.json");
|
|
86
|
+
const packageJson = JSON.parse(await readFile(packageJsonPath, "utf-8"));
|
|
87
|
+
description = packageJson.description || "";
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error?.code !== "ENOENT") {
|
|
91
|
+
logger.warn(`Failed to read package.json for ${dir.name}:`, error);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
logger.debug(`No package.json found for example: ${dir.name}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const files = await scanDirectory(examplePath, examplePath);
|
|
98
|
+
files.sort((a, b) => a.path.localeCompare(b.path));
|
|
99
|
+
let markdown = `# Example: ${dir.name}\n\n`;
|
|
100
|
+
if (description) {
|
|
101
|
+
markdown += `${description}\n\n`;
|
|
102
|
+
}
|
|
103
|
+
let totalLines = 0;
|
|
104
|
+
for (const file of files) {
|
|
105
|
+
const lines = file.content.split("\n").length;
|
|
106
|
+
if (totalLines + lines > MAX_LINES) {
|
|
107
|
+
markdown += `\n_Note: Additional files truncated due to size limits_\n`;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
// Normalize Windows backslashes to forward slashes for consistent markdown output
|
|
111
|
+
markdown += `## ${file.path.replace(/\\/g, "/")}\n\n`;
|
|
112
|
+
markdown += `\`\`\`${getFileType(file.path)}\n`;
|
|
113
|
+
markdown += file.content;
|
|
114
|
+
markdown += `\n\`\`\`\n\n`;
|
|
115
|
+
totalLines += lines;
|
|
116
|
+
}
|
|
117
|
+
const outputPath = join(OUTPUT_DIR, `${dir.name}.md`);
|
|
118
|
+
await writeFile(outputPath, markdown, "utf-8");
|
|
119
|
+
logger.debug(`Created example: ${outputPath}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
logger.info("Code examples preparation complete");
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
logger.error("Failed to prepare code examples", error);
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=code-examples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-examples.js","sourceRoot":"","sources":["../../src/prepare-docs/code-examples.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1D,MAAM,UAAU,GAAG,IAAI,CACrB,QAAQ,EACR,wDAAwD,CACzD,CAAC;AACF,MAAM,SAAS,GAAG,KAAK,CAAC;AAOxB,KAAK,UAAU,aAAa,CAC1B,GAAW,EACX,OAAe;IAEf,MAAM,KAAK,GAAkB,EAAE,CAAC;IAEhC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAE5D,KAAK,MAAM,KAAK,IAAI,OAA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IAAI,CAAC,CAAC,MAAM,CAAC;oBAC9C,IAAI,UAAU,GAAG,KAAK,GAAG,SAAS,EAAE,CAAC;wBACnC,QAAQ,IAAI,2DAA2D,CAAC;wBACxE,MAAM;oBACR,CAAC;oBAED,kFAAkF;oBAClF,QAAQ,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC;oBACtD,QAAQ,IAAI,SAAS,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;oBAChD,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC;oBACzB,QAAQ,IAAI,cAAc,CAAC;oBAE3B,UAAU,IAAI,KAAK,CAAC;gBACtB,CAAC;gBAED,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC;gBACtD,MAAM,SAAS,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;gBAC/C,MAAM,CAAC,KAAK,CAAC,oBAAoB,UAAU,EAAE,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;QACvD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-raw.d.ts","sourceRoot":"","sources":["../../src/prepare-docs/copy-raw.ts"],"names":[],"mappings":"AAkCA,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAoB7C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { rm, mkdir, readdir, copyFile } from "node:fs/promises";
|
|
2
|
+
import { join, extname } from "node:path";
|
|
3
|
+
import { logger } from "../utils/logger.js";
|
|
4
|
+
import { ROOT_DIR } from "../constants.js";
|
|
5
|
+
const DOCS_SOURCE = join(ROOT_DIR, "apps/docs/content/docs");
|
|
6
|
+
const BLOG_SOURCE = join(ROOT_DIR, "apps/docs/content/blog");
|
|
7
|
+
const DOCS_DEST = join(ROOT_DIR, "packages/mcp-docs-server/.docs/raw");
|
|
8
|
+
async function copyDir(src, dest) {
|
|
9
|
+
try {
|
|
10
|
+
await mkdir(dest, { recursive: true });
|
|
11
|
+
const entries = await readdir(src, { withFileTypes: true });
|
|
12
|
+
for (const entry of entries) {
|
|
13
|
+
const srcPath = join(src, entry.name);
|
|
14
|
+
const destPath = join(dest, entry.name);
|
|
15
|
+
if (entry.isDirectory()) {
|
|
16
|
+
await copyDir(srcPath, destPath);
|
|
17
|
+
}
|
|
18
|
+
else if (entry.isFile()) {
|
|
19
|
+
const ext = extname(entry.name).toLowerCase();
|
|
20
|
+
if (ext === ".mdx" || ext === ".md") {
|
|
21
|
+
await copyFile(srcPath, destPath);
|
|
22
|
+
logger.debug(`Copied: ${srcPath} -> ${destPath}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
logger.error(`Failed to copy directory: ${src}`, error);
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function copyRaw() {
|
|
33
|
+
logger.info("Copying raw documentation files...");
|
|
34
|
+
try {
|
|
35
|
+
await rm(DOCS_DEST, { recursive: true, force: true });
|
|
36
|
+
await mkdir(DOCS_DEST, { recursive: true });
|
|
37
|
+
const docsPath = join(DOCS_DEST, "docs");
|
|
38
|
+
await copyDir(DOCS_SOURCE, docsPath);
|
|
39
|
+
logger.info(`Copied documentation to ${docsPath}`);
|
|
40
|
+
const blogPath = join(DOCS_DEST, "blog");
|
|
41
|
+
await copyDir(BLOG_SOURCE, blogPath);
|
|
42
|
+
logger.info(`Copied blog posts to ${blogPath}`);
|
|
43
|
+
logger.info("Raw documentation copy complete");
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
logger.error("Failed to copy raw documentation", error);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=copy-raw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-raw.js","sourceRoot":"","sources":["../../src/prepare-docs/copy-raw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;AAC7D,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;AAC7D,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,oCAAoC,CAAC,CAAC;AAEvE,KAAK,UAAU,OAAO,CAAC,GAAW,EAAE,IAAY;IAC9C,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAE5D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAExC,IAAI,KAAK,CAAC,WAAW,EAAE,E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AAC,wBAAwB,QAAQ,EAAE,CAAC,CAAC;QAEhD,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;QACxD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../src/prepare-docs/prepare.ts"],"names":[],"mappings":""}
|
|
@@ -1,199 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
await mkdir(dest, { recursive: true });
|
|
11
|
-
const entries = await readdir(src, { withFileTypes: true });
|
|
12
|
-
for (const entry of entries) {
|
|
13
|
-
const srcPath = join(src, entry.name);
|
|
14
|
-
const destPath = join(dest, entry.name);
|
|
15
|
-
if (entry.isDirectory()) {
|
|
16
|
-
await copyDir(srcPath, destPath);
|
|
17
|
-
} else if (entry.isFile()) {
|
|
18
|
-
const ext = extname(entry.name).toLowerCase();
|
|
19
|
-
if (ext === ".mdx" || ext === ".md") {
|
|
20
|
-
await copyFile(srcPath, destPath);
|
|
21
|
-
logger.debug(`Copied: ${srcPath} -> ${destPath}`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
} catch (error) {
|
|
26
|
-
logger.error(`Failed to copy directory: ${src}`, error);
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async function copyRaw() {
|
|
31
|
-
logger.info("Copying raw documentation files...");
|
|
32
|
-
try {
|
|
33
|
-
await rm(DOCS_DEST, { recursive: true, force: true });
|
|
34
|
-
await mkdir(DOCS_DEST, { recursive: true });
|
|
35
|
-
const docsPath = join(DOCS_DEST, "docs");
|
|
36
|
-
await copyDir(DOCS_SOURCE, docsPath);
|
|
37
|
-
logger.info(`Copied documentation to ${docsPath}`);
|
|
38
|
-
const blogPath = join(DOCS_DEST, "blog");
|
|
39
|
-
await copyDir(BLOG_SOURCE, blogPath);
|
|
40
|
-
logger.info(`Copied blog posts to ${blogPath}`);
|
|
41
|
-
logger.info("Raw documentation copy complete");
|
|
42
|
-
} catch (error) {
|
|
43
|
-
logger.error("Failed to copy raw documentation", error);
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
var OUTPUT_DIR = join(
|
|
48
|
-
ROOT_DIR,
|
|
49
|
-
"packages/mcp-docs-server/.docs/organized/code-examples"
|
|
50
|
-
);
|
|
51
|
-
var MAX_LINES = 1e4;
|
|
52
|
-
async function scanDirectory(dir, baseDir) {
|
|
53
|
-
const files = [];
|
|
54
|
-
try {
|
|
55
|
-
const entries = await readdir(dir, { withFileTypes: true });
|
|
56
|
-
for (const entry of entries) {
|
|
57
|
-
const fullPath = join(dir, entry.name);
|
|
58
|
-
if (entry.isDirectory()) {
|
|
59
|
-
const skipDirs = [
|
|
60
|
-
"node_modules",
|
|
61
|
-
"dist",
|
|
62
|
-
"build",
|
|
63
|
-
".next",
|
|
64
|
-
".git",
|
|
65
|
-
".turbo"
|
|
66
|
-
];
|
|
67
|
-
if (!skipDirs.includes(entry.name)) {
|
|
68
|
-
const subFiles = await scanDirectory(fullPath, baseDir);
|
|
69
|
-
files.push(...subFiles);
|
|
70
|
-
}
|
|
71
|
-
} else if (entry.isFile()) {
|
|
72
|
-
const includeExts = [
|
|
73
|
-
".ts",
|
|
74
|
-
".tsx",
|
|
75
|
-
".js",
|
|
76
|
-
".jsx",
|
|
77
|
-
".json",
|
|
78
|
-
".css",
|
|
79
|
-
".md",
|
|
80
|
-
".mdx"
|
|
81
|
-
];
|
|
82
|
-
const ext = extname(entry.name).toLowerCase();
|
|
83
|
-
if (includeExts.includes(ext) || entry.name === "package.json" || entry.name === "tsconfig.json") {
|
|
84
|
-
try {
|
|
85
|
-
const content = await readFile(fullPath, "utf-8");
|
|
86
|
-
const relativePath = relative(baseDir, fullPath);
|
|
87
|
-
files.push({ path: relativePath, content });
|
|
88
|
-
} catch (error) {
|
|
89
|
-
logger.warn(`Failed to read file: ${fullPath}`, error);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
1
|
+
import { logger } from "../utils/logger.js";
|
|
2
|
+
import { copyRaw } from "./copy-raw.js";
|
|
3
|
+
import { prepareCodeExamples } from "./code-examples.js";
|
|
4
|
+
async function prepare() {
|
|
5
|
+
logger.info("Starting documentation preparation...");
|
|
6
|
+
try {
|
|
7
|
+
await copyRaw();
|
|
8
|
+
await prepareCodeExamples();
|
|
9
|
+
logger.info("Documentation preparation complete");
|
|
93
10
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return files;
|
|
98
|
-
}
|
|
99
|
-
function getFileType(filename) {
|
|
100
|
-
const ext = extname(filename).toLowerCase();
|
|
101
|
-
const extMap = {
|
|
102
|
-
".ts": "typescript",
|
|
103
|
-
".tsx": "tsx",
|
|
104
|
-
".js": "javascript",
|
|
105
|
-
".jsx": "jsx",
|
|
106
|
-
".json": "json",
|
|
107
|
-
".css": "css",
|
|
108
|
-
".md": "markdown",
|
|
109
|
-
".mdx": "mdx"
|
|
110
|
-
};
|
|
111
|
-
return extMap[ext] || "text";
|
|
112
|
-
}
|
|
113
|
-
async function prepareCodeExamples() {
|
|
114
|
-
logger.info("Preparing code examples...");
|
|
115
|
-
try {
|
|
116
|
-
await rm(OUTPUT_DIR, { recursive: true, force: true });
|
|
117
|
-
await mkdir(OUTPUT_DIR, { recursive: true });
|
|
118
|
-
const exampleDirs = await readdir(EXAMPLES_PATH, { withFileTypes: true });
|
|
119
|
-
for (const dir of exampleDirs) {
|
|
120
|
-
if (dir.isDirectory() && !dir.name.startsWith(".")) {
|
|
121
|
-
const examplePath = join(EXAMPLES_PATH, dir.name);
|
|
122
|
-
logger.info(`Processing example: ${dir.name}`);
|
|
123
|
-
let description = "";
|
|
124
|
-
try {
|
|
125
|
-
const packageJsonPath = join(examplePath, "package.json");
|
|
126
|
-
const packageJson = JSON.parse(
|
|
127
|
-
await readFile(packageJsonPath, "utf-8")
|
|
128
|
-
);
|
|
129
|
-
description = packageJson.description || "";
|
|
130
|
-
} catch (error) {
|
|
131
|
-
if (error?.code !== "ENOENT") {
|
|
132
|
-
logger.warn(`Failed to read package.json for ${dir.name}:`, error);
|
|
133
|
-
} else {
|
|
134
|
-
logger.debug(`No package.json found for example: ${dir.name}`);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
const files = await scanDirectory(examplePath, examplePath);
|
|
138
|
-
files.sort((a, b) => a.path.localeCompare(b.path));
|
|
139
|
-
let markdown = `# Example: ${dir.name}
|
|
140
|
-
|
|
141
|
-
`;
|
|
142
|
-
if (description) {
|
|
143
|
-
markdown += `${description}
|
|
144
|
-
|
|
145
|
-
`;
|
|
146
|
-
}
|
|
147
|
-
let totalLines = 0;
|
|
148
|
-
for (const file of files) {
|
|
149
|
-
const lines = file.content.split("\n").length;
|
|
150
|
-
if (totalLines + lines > MAX_LINES) {
|
|
151
|
-
markdown += `
|
|
152
|
-
_Note: Additional files truncated due to size limits_
|
|
153
|
-
`;
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
markdown += `## ${file.path.replace(/\\/g, "/")}
|
|
157
|
-
|
|
158
|
-
`;
|
|
159
|
-
markdown += `\`\`\`${getFileType(file.path)}
|
|
160
|
-
`;
|
|
161
|
-
markdown += file.content;
|
|
162
|
-
markdown += `
|
|
163
|
-
\`\`\`
|
|
164
|
-
|
|
165
|
-
`;
|
|
166
|
-
totalLines += lines;
|
|
167
|
-
}
|
|
168
|
-
const outputPath = join(OUTPUT_DIR, `${dir.name}.md`);
|
|
169
|
-
await writeFile(outputPath, markdown, "utf-8");
|
|
170
|
-
logger.debug(`Created example: ${outputPath}`);
|
|
171
|
-
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
logger.error("Documentation preparation failed", error);
|
|
13
|
+
throw error;
|
|
172
14
|
}
|
|
173
|
-
logger.info("Code examples preparation complete");
|
|
174
|
-
} catch (error) {
|
|
175
|
-
logger.error("Failed to prepare code examples", error);
|
|
176
|
-
throw error;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// src/prepare-docs/prepare.ts
|
|
181
|
-
async function prepare() {
|
|
182
|
-
logger.info("Starting documentation preparation...");
|
|
183
|
-
try {
|
|
184
|
-
await copyRaw();
|
|
185
|
-
await prepareCodeExamples();
|
|
186
|
-
logger.info("Documentation preparation complete");
|
|
187
|
-
} catch (error) {
|
|
188
|
-
logger.error("Documentation preparation failed", error);
|
|
189
|
-
throw error;
|
|
190
|
-
}
|
|
191
15
|
}
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
16
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
17
|
+
prepare().catch((error) => {
|
|
18
|
+
logger.error("Preparation failed", error);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
});
|
|
197
21
|
}
|
|
198
|
-
|
|
199
|
-
export { prepare };
|
|
22
|
+
//# sourceMappingURL=prepare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../src/prepare-docs/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,KAAK,UAAU,OAAO;IACpB,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IAErD,IAAI,CAAC;QACH,MAAM,OAAO,EAAE,CAAC;QAChB,MAAM,mBAAmB,EAAE,CAAC;QAE5B,MAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;QACxD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpD,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACxB,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;QAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/stdio.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":""}
|
package/dist/stdio.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { runServer } from
|
|
3
|
-
|
|
4
|
-
// src/stdio.ts
|
|
2
|
+
import { runServer } from "./index.js";
|
|
5
3
|
void runServer().catch((error) => {
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
console.error("Failed to start server:", error);
|
|
5
|
+
process.exit(1);
|
|
8
6
|
});
|
|
7
|
+
//# sourceMappingURL=stdio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,KAAK,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC/B,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;IAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod/v3";
|
|
2
|
+
declare const docsInputSchema: z.ZodObject<{
|
|
3
|
+
paths: z.ZodArray<z.ZodString, "many">;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
paths: string[];
|
|
6
|
+
}, {
|
|
7
|
+
paths: string[];
|
|
8
|
+
}>;
|
|
9
|
+
export declare const docsTools: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
parameters: {
|
|
13
|
+
paths: z.ZodArray<z.ZodString, "many">;
|
|
14
|
+
};
|
|
15
|
+
execute: ({ paths }: z.infer<typeof docsInputSchema>) => Promise<{
|
|
16
|
+
content: Array<{
|
|
17
|
+
type: "text";
|
|
18
|
+
text: string;
|
|
19
|
+
}>;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/tools/docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAe3B,QAAA,MAAM,eAAe;;;;;;EAOnB,CAAC;AA6IH,eAAO,MAAM,SAAS;;;;;;yBAKO,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC;;;;;;CAsC3D,CAAC"}
|