@xano/developer-mcp 1.0.74 → 2.0.0-beta.0
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/README.md +104 -37
- package/dist/cli_docs/index.d.ts +13 -37
- package/dist/cli_docs/index.js +28 -39
- package/dist/cli_docs/topics/integration.js +1 -1
- package/dist/cli_docs/topics/workspace.js +1 -1
- package/dist/index.js +58 -55
- package/dist/lib.d.ts +3 -1
- package/dist/lib.js +1 -1
- package/dist/meta_api_docs/format.js +1 -1
- package/dist/meta_api_docs/index.d.ts +14 -42
- package/dist/meta_api_docs/index.js +34 -46
- package/dist/tools/cli_docs.d.ts +2 -3
- package/dist/tools/cli_docs.js +3 -5
- package/dist/tools/define_tool.d.ts +47 -0
- package/dist/tools/define_tool.js +36 -0
- package/dist/tools/index.d.ts +88 -221
- package/dist/tools/index.js +80 -109
- package/dist/tools/mcp_version.d.ts +4 -25
- package/dist/tools/mcp_version.js +12 -19
- package/dist/tools/meta_api_docs.d.ts +2 -3
- package/dist/tools/meta_api_docs.js +3 -5
- package/dist/tools/validate_xanoscript.d.ts +18 -65
- package/dist/tools/validate_xanoscript.js +56 -54
- package/dist/tools/xanoscript_docs.d.ts +25 -74
- package/dist/tools/xanoscript_docs.js +86 -83
- package/dist/xanoscript_docs/README.md +5 -5
- package/dist/xanoscript_docs/addons.md +1 -3
- package/dist/xanoscript_docs/apis.md +2 -2
- package/dist/xanoscript_docs/database.md +1 -1
- package/dist/xanoscript_docs/essentials.md +6 -6
- package/dist/xanoscript_docs/functions.md +3 -3
- package/dist/xanoscript_docs/integrations.md +5 -5
- package/dist/xanoscript_docs/middleware.md +1 -1
- package/dist/xanoscript_docs/performance.md +4 -4
- package/dist/xanoscript_docs/realtime.md +2 -2
- package/dist/xanoscript_docs/security.md +3 -6
- package/dist/xanoscript_docs/survival.md +1 -1
- package/dist/xanoscript_docs/syntax/string-filters.md +1 -1
- package/dist/xanoscript_docs/syntax.md +10 -12
- package/dist/xanoscript_docs/tasks.md +1 -2
- package/dist/xanoscript_docs/tools.md +3 -5
- package/dist/xanoscript_docs/types.md +2 -2
- package/dist/xanoscript_docs/unit-testing.md +1 -1
- package/dist/xanoscript_docs/workflow-tests.md +1 -1
- package/dist/xanoscript_docs/working.md +4 -4
- package/package.json +5 -4
- package/dist/api_docs/format.d.ts +0 -5
- package/dist/api_docs/format.js +0 -171
- package/dist/api_docs/index.d.ts +0 -52
- package/dist/api_docs/index.js +0 -111
- package/dist/api_docs/topics/agent.d.ts +0 -2
- package/dist/api_docs/topics/agent.js +0 -142
- package/dist/api_docs/topics/api.d.ts +0 -2
- package/dist/api_docs/topics/api.js +0 -176
- package/dist/api_docs/topics/apigroup.d.ts +0 -2
- package/dist/api_docs/topics/apigroup.js +0 -124
- package/dist/api_docs/topics/authentication.d.ts +0 -2
- package/dist/api_docs/topics/authentication.js +0 -61
- package/dist/api_docs/topics/branch.d.ts +0 -2
- package/dist/api_docs/topics/branch.js +0 -73
- package/dist/api_docs/topics/file.d.ts +0 -2
- package/dist/api_docs/topics/file.js +0 -70
- package/dist/api_docs/topics/function.d.ts +0 -2
- package/dist/api_docs/topics/function.js +0 -164
- package/dist/api_docs/topics/history.d.ts +0 -2
- package/dist/api_docs/topics/history.js +0 -149
- package/dist/api_docs/topics/mcp_server.d.ts +0 -2
- package/dist/api_docs/topics/mcp_server.js +0 -139
- package/dist/api_docs/topics/middleware.d.ts +0 -2
- package/dist/api_docs/topics/middleware.js +0 -156
- package/dist/api_docs/topics/realtime.d.ts +0 -2
- package/dist/api_docs/topics/realtime.js +0 -112
- package/dist/api_docs/topics/start.d.ts +0 -2
- package/dist/api_docs/topics/start.js +0 -107
- package/dist/api_docs/topics/table.d.ts +0 -2
- package/dist/api_docs/topics/table.js +0 -195
- package/dist/api_docs/topics/task.d.ts +0 -2
- package/dist/api_docs/topics/task.js +0 -165
- package/dist/api_docs/topics/tool.d.ts +0 -2
- package/dist/api_docs/topics/tool.js +0 -150
- package/dist/api_docs/topics/workflows.d.ts +0 -2
- package/dist/api_docs/topics/workflows.js +0 -131
- package/dist/api_docs/topics/workspace.d.ts +0 -2
- package/dist/api_docs/topics/workspace.js +0 -153
- package/dist/api_docs/types.d.ts +0 -79
- package/dist/api_docs/types.js +0 -4
- package/dist/cli_docs/topics/run.d.ts +0 -2
- package/dist/cli_docs/topics/run.js +0 -248
- package/dist/meta_api_docs/format.test.d.ts +0 -1
- package/dist/meta_api_docs/format.test.js +0 -272
- package/dist/meta_api_docs/index.test.d.ts +0 -1
- package/dist/meta_api_docs/index.test.js +0 -128
- package/dist/meta_api_docs/types.test.d.ts +0 -1
- package/dist/meta_api_docs/types.test.js +0 -132
- package/dist/templates/init-workspace.d.ts +0 -10
- package/dist/templates/init-workspace.js +0 -278
- package/dist/templates/xanoscript-index.d.ts +0 -11
- package/dist/templates/xanoscript-index.js +0 -72
- package/dist/tools/index.test.d.ts +0 -1
- package/dist/tools/index.test.js +0 -179
- package/dist/tools/xanoscript_docs.test.d.ts +0 -1
- package/dist/tools/xanoscript_docs.test.js +0 -197
- package/dist/xanoscript.test.d.ts +0 -1
- package/dist/xanoscript.test.js +0 -421
- package/dist/xanoscript_docs/cheatsheet.md +0 -287
- package/dist/xanoscript_docs/ephemeral.md +0 -330
- package/dist/xanoscript_docs/quickstart.md +0 -692
- package/dist/xanoscript_docs/run.md +0 -196
- package/dist/xanoscript_docs/schema.md +0 -300
- package/dist/xanoscript_docs_auto/README.md +0 -119
- package/dist/xanoscript_docs_auto/agents.md +0 -446
- package/dist/xanoscript_docs_auto/apis.md +0 -517
- package/dist/xanoscript_docs_auto/control-flow.md +0 -543
- package/dist/xanoscript_docs_auto/database.md +0 -551
- package/dist/xanoscript_docs_auto/debugging.md +0 -527
- package/dist/xanoscript_docs_auto/filters.md +0 -464
- package/dist/xanoscript_docs_auto/functions.md +0 -431
- package/dist/xanoscript_docs_auto/integrations.md +0 -657
- package/dist/xanoscript_docs_auto/mcp-servers.md +0 -408
- package/dist/xanoscript_docs_auto/operators.md +0 -368
- package/dist/xanoscript_docs_auto/syntax.md +0 -287
- package/dist/xanoscript_docs_auto/tables.md +0 -447
- package/dist/xanoscript_docs_auto/tasks.md +0 -479
- package/dist/xanoscript_docs_auto/testing.md +0 -574
- package/dist/xanoscript_docs_auto/tools.md +0 -485
- package/dist/xanoscript_docs_auto/triggers.md +0 -595
- package/dist/xanoscript_docs_auto/types.md +0 -323
- package/dist/xanoscript_docs_auto/variables.md +0 -462
- package/dist/xanoscript_docs_auto/version.json +0 -5
package/dist/tools/index.test.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeAll } from "vitest";
|
|
2
|
-
import { join, dirname } from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { existsSync } from "fs";
|
|
5
|
-
import { handleTool, toMcpResponse, toolDefinitions, } from "./index.js";
|
|
6
|
-
import { setXanoscriptDocsPath } from "./xanoscript_docs.js";
|
|
7
|
-
import { XANOSCRIPT_DOCS_V2 } from "../xanoscript.js";
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = dirname(__filename);
|
|
10
|
-
const DOCS_PATH = join(__dirname, "..", "xanoscript_docs");
|
|
11
|
-
beforeAll(() => {
|
|
12
|
-
setXanoscriptDocsPath(DOCS_PATH);
|
|
13
|
-
});
|
|
14
|
-
describe("handleTool", () => {
|
|
15
|
-
it("should handle xanoscript_docs tool", () => {
|
|
16
|
-
const result = handleTool("xanoscript_docs", {});
|
|
17
|
-
expect(result.success).toBe(true);
|
|
18
|
-
expect(result.data).toBeDefined();
|
|
19
|
-
});
|
|
20
|
-
it("should handle xanoscript_docs with topic arg", () => {
|
|
21
|
-
const result = handleTool("xanoscript_docs", { topic: "syntax" });
|
|
22
|
-
expect(result.success).toBe(true);
|
|
23
|
-
expect(typeof result.data).toBe("string");
|
|
24
|
-
expect(result.data).toContain("Documentation version:");
|
|
25
|
-
});
|
|
26
|
-
it("should handle xanoscript_docs with file_path and return multi-content", () => {
|
|
27
|
-
const result = handleTool("xanoscript_docs", { file_path: "api/users/create.xs" });
|
|
28
|
-
expect(result.success).toBe(true);
|
|
29
|
-
expect(Array.isArray(result.data)).toBe(true);
|
|
30
|
-
const data = result.data;
|
|
31
|
-
expect(data.length).toBeGreaterThan(1);
|
|
32
|
-
expect(data[0]).toContain("Matched topics:");
|
|
33
|
-
});
|
|
34
|
-
it("should handle validate_xanoscript tool and return a ToolResult", () => {
|
|
35
|
-
const result = handleTool("validate_xanoscript", { code: "var $x:int = 1" });
|
|
36
|
-
expect(result).toHaveProperty("success");
|
|
37
|
-
expect(typeof result.success).toBe("boolean");
|
|
38
|
-
// Either data or error should be present
|
|
39
|
-
expect(result.data ?? result.error).toBeDefined();
|
|
40
|
-
});
|
|
41
|
-
it("should handle validate_xanoscript with missing input", () => {
|
|
42
|
-
const result = handleTool("validate_xanoscript", {});
|
|
43
|
-
expect(result.success).toBe(false);
|
|
44
|
-
expect(result.error).toBeDefined();
|
|
45
|
-
});
|
|
46
|
-
it("should handle mcp_version tool", () => {
|
|
47
|
-
const result = handleTool("mcp_version", {});
|
|
48
|
-
expect(result.success).toBe(true);
|
|
49
|
-
expect(result.data).toBeDefined();
|
|
50
|
-
});
|
|
51
|
-
it("should handle meta_api_docs tool with topic", () => {
|
|
52
|
-
const result = handleTool("meta_api_docs", { topic: "start" });
|
|
53
|
-
expect(result.success).toBe(true);
|
|
54
|
-
expect(result.data).toBeDefined();
|
|
55
|
-
});
|
|
56
|
-
it("should handle meta_api_docs tool without topic", () => {
|
|
57
|
-
const result = handleTool("meta_api_docs", {});
|
|
58
|
-
expect(result.success).toBe(false);
|
|
59
|
-
expect(result.error).toContain("topic");
|
|
60
|
-
});
|
|
61
|
-
it("should handle cli_docs tool with topic", () => {
|
|
62
|
-
const result = handleTool("cli_docs", { topic: "start" });
|
|
63
|
-
expect(result.success).toBe(true);
|
|
64
|
-
expect(result.data).toBeDefined();
|
|
65
|
-
});
|
|
66
|
-
it("should handle cli_docs tool without topic", () => {
|
|
67
|
-
const result = handleTool("cli_docs", {});
|
|
68
|
-
expect(result.success).toBe(false);
|
|
69
|
-
expect(result.error).toContain("topic");
|
|
70
|
-
});
|
|
71
|
-
it("should return error for unknown tool", () => {
|
|
72
|
-
const result = handleTool("nonexistent_tool", {});
|
|
73
|
-
expect(result.success).toBe(false);
|
|
74
|
-
expect(result.error).toContain("Unknown tool: nonexistent_tool");
|
|
75
|
-
});
|
|
76
|
-
it("should return validation error for wrong argument types", () => {
|
|
77
|
-
const result = handleTool("xanoscript_docs", { mode: 123 });
|
|
78
|
-
expect(result.success).toBe(false);
|
|
79
|
-
expect(result.error).toContain("Invalid arguments");
|
|
80
|
-
});
|
|
81
|
-
it("should return validation error for invalid enum value", () => {
|
|
82
|
-
const result = handleTool("xanoscript_docs", { mode: "invalid_mode" });
|
|
83
|
-
expect(result.success).toBe(false);
|
|
84
|
-
expect(result.error).toContain("Invalid arguments");
|
|
85
|
-
});
|
|
86
|
-
it("should return validation error when meta_api_docs topic is wrong type", () => {
|
|
87
|
-
const result = handleTool("meta_api_docs", { topic: 123 });
|
|
88
|
-
expect(result.success).toBe(false);
|
|
89
|
-
expect(result.error).toContain("Invalid arguments");
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
describe("toMcpResponse", () => {
|
|
93
|
-
it("should convert success result to MCP response", () => {
|
|
94
|
-
const response = toMcpResponse({ success: true, data: "test data" });
|
|
95
|
-
expect(response.content).toHaveLength(1);
|
|
96
|
-
expect(response.content[0].type).toBe("text");
|
|
97
|
-
expect(response.content[0].text).toBe("test data");
|
|
98
|
-
expect(response.isError).toBeUndefined();
|
|
99
|
-
});
|
|
100
|
-
it("should convert error result to MCP response with isError", () => {
|
|
101
|
-
const response = toMcpResponse({ success: false, error: "test error" });
|
|
102
|
-
expect(response.content).toHaveLength(1);
|
|
103
|
-
expect(response.content[0].text).toBe("test error");
|
|
104
|
-
expect(response.isError).toBe(true);
|
|
105
|
-
});
|
|
106
|
-
it("should convert string array data to multiple content blocks", () => {
|
|
107
|
-
const response = toMcpResponse({
|
|
108
|
-
success: true,
|
|
109
|
-
data: ["block one", "block two", "block three"],
|
|
110
|
-
});
|
|
111
|
-
expect(response.content).toHaveLength(3);
|
|
112
|
-
expect(response.content[0]).toEqual({ type: "text", text: "block one" });
|
|
113
|
-
expect(response.content[1]).toEqual({ type: "text", text: "block two" });
|
|
114
|
-
expect(response.content[2]).toEqual({ type: "text", text: "block three" });
|
|
115
|
-
expect(response.isError).toBeUndefined();
|
|
116
|
-
});
|
|
117
|
-
it("should handle single-element array data", () => {
|
|
118
|
-
const response = toMcpResponse({ success: true, data: ["only block"] });
|
|
119
|
-
expect(response.content).toHaveLength(1);
|
|
120
|
-
expect(response.content[0].text).toBe("only block");
|
|
121
|
-
});
|
|
122
|
-
it("should include structuredContent when provided", () => {
|
|
123
|
-
const response = toMcpResponse({
|
|
124
|
-
success: true,
|
|
125
|
-
data: "test",
|
|
126
|
-
structuredContent: { version: "1.0.0" },
|
|
127
|
-
});
|
|
128
|
-
expect(response.structuredContent).toEqual({ version: "1.0.0" });
|
|
129
|
-
expect(response.isError).toBeUndefined();
|
|
130
|
-
});
|
|
131
|
-
it("should omit structuredContent when not provided", () => {
|
|
132
|
-
const response = toMcpResponse({ success: true, data: "test" });
|
|
133
|
-
expect(response.structuredContent).toBeUndefined();
|
|
134
|
-
});
|
|
135
|
-
it("should not include structuredContent on error", () => {
|
|
136
|
-
const response = toMcpResponse({ success: false, error: "fail" });
|
|
137
|
-
expect(response.structuredContent).toBeUndefined();
|
|
138
|
-
expect(response.isError).toBe(true);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
describe("toolDefinitions", () => {
|
|
142
|
-
it("should contain all 5 tools", () => {
|
|
143
|
-
expect(toolDefinitions).toHaveLength(5);
|
|
144
|
-
});
|
|
145
|
-
it("should have unique tool names", () => {
|
|
146
|
-
const names = toolDefinitions.map((t) => t.name);
|
|
147
|
-
expect(new Set(names).size).toBe(names.length);
|
|
148
|
-
});
|
|
149
|
-
it("should include expected tool names", () => {
|
|
150
|
-
const names = toolDefinitions.map((t) => t.name);
|
|
151
|
-
expect(names).toContain("validate_xanoscript");
|
|
152
|
-
expect(names).toContain("xanoscript_docs");
|
|
153
|
-
expect(names).toContain("mcp_version");
|
|
154
|
-
expect(names).toContain("meta_api_docs");
|
|
155
|
-
expect(names).toContain("cli_docs");
|
|
156
|
-
});
|
|
157
|
-
it("should have annotations on all tools", () => {
|
|
158
|
-
for (const tool of toolDefinitions) {
|
|
159
|
-
expect(tool).toHaveProperty("annotations");
|
|
160
|
-
expect(tool.annotations).toHaveProperty("readOnlyHint");
|
|
161
|
-
expect(tool.annotations).toHaveProperty("destructiveHint", false);
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
it("should have outputSchema on all tools", () => {
|
|
165
|
-
for (const tool of toolDefinitions) {
|
|
166
|
-
expect(tool).toHaveProperty("outputSchema");
|
|
167
|
-
expect(tool.outputSchema).toHaveProperty("type", "object");
|
|
168
|
-
expect(tool.outputSchema).toHaveProperty("properties");
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
describe("integration: all topic files exist on disk", () => {
|
|
173
|
-
for (const [topic, config] of Object.entries(XANOSCRIPT_DOCS_V2)) {
|
|
174
|
-
it(`topic "${topic}" -> file "${config.file}" should exist`, () => {
|
|
175
|
-
const filePath = join(DOCS_PATH, config.file);
|
|
176
|
-
expect(existsSync(filePath)).toBe(true);
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from "vitest";
|
|
2
|
-
import { join, dirname } from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { getXanoscriptDocsPath, setXanoscriptDocsPath, xanoscriptDocs, xanoscriptDocsTool, } from "./xanoscript_docs.js";
|
|
5
|
-
import { toMcpResponse } from "./types.js";
|
|
6
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
-
const __dirname = dirname(__filename);
|
|
8
|
-
const DOCS_PATH = join(__dirname, "..", "xanoscript_docs");
|
|
9
|
-
afterEach(() => {
|
|
10
|
-
// Reset to default so tests don't interfere with each other
|
|
11
|
-
setXanoscriptDocsPath(DOCS_PATH);
|
|
12
|
-
});
|
|
13
|
-
describe("getXanoscriptDocsPath", () => {
|
|
14
|
-
it("should return a string path", () => {
|
|
15
|
-
const path = getXanoscriptDocsPath();
|
|
16
|
-
expect(typeof path).toBe("string");
|
|
17
|
-
expect(path.length).toBeGreaterThan(0);
|
|
18
|
-
});
|
|
19
|
-
it("should return a path ending with xanoscript_docs", () => {
|
|
20
|
-
const path = getXanoscriptDocsPath();
|
|
21
|
-
expect(path).toMatch(/xanoscript_docs$/);
|
|
22
|
-
});
|
|
23
|
-
it("should return a consistent path on repeated calls", () => {
|
|
24
|
-
const path1 = getXanoscriptDocsPath();
|
|
25
|
-
const path2 = getXanoscriptDocsPath();
|
|
26
|
-
expect(path1).toBe(path2);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe("setXanoscriptDocsPath", () => {
|
|
30
|
-
it("should override the docs path", () => {
|
|
31
|
-
const customPath = "/custom/docs/path";
|
|
32
|
-
setXanoscriptDocsPath(customPath);
|
|
33
|
-
expect(getXanoscriptDocsPath()).toBe(customPath);
|
|
34
|
-
});
|
|
35
|
-
it("should be used by xanoscriptDocs when set", () => {
|
|
36
|
-
setXanoscriptDocsPath(DOCS_PATH);
|
|
37
|
-
const result = xanoscriptDocs();
|
|
38
|
-
expect(result.documentation).toContain("Documentation version:");
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe("xanoscriptDocs", () => {
|
|
42
|
-
it("should return README when called with no args", () => {
|
|
43
|
-
const result = xanoscriptDocs();
|
|
44
|
-
expect(result).toHaveProperty("documentation");
|
|
45
|
-
expect(typeof result.documentation).toBe("string");
|
|
46
|
-
expect(result.documentation).toContain("Documentation version:");
|
|
47
|
-
});
|
|
48
|
-
it("should return specific topic documentation", () => {
|
|
49
|
-
const result = xanoscriptDocs({ topic: "syntax" });
|
|
50
|
-
expect(result.documentation).toContain("Documentation version:");
|
|
51
|
-
});
|
|
52
|
-
it("should return context-aware docs for file_path", () => {
|
|
53
|
-
const result = xanoscriptDocs({ file_path: "api/users/create.xs" });
|
|
54
|
-
expect(result.documentation).toContain("XanoScript Documentation for:");
|
|
55
|
-
expect(result.documentation).toContain("Matched topics:");
|
|
56
|
-
});
|
|
57
|
-
it("should support quick_reference mode", () => {
|
|
58
|
-
const full = xanoscriptDocs({ topic: "syntax", mode: "full" });
|
|
59
|
-
const quick = xanoscriptDocs({ topic: "syntax", mode: "quick_reference" });
|
|
60
|
-
expect(quick.documentation.length).toBeLessThanOrEqual(full.documentation.length);
|
|
61
|
-
});
|
|
62
|
-
it("should throw for unknown topic", () => {
|
|
63
|
-
expect(() => xanoscriptDocs({ topic: "nonexistent" })).toThrow('Unknown topic "nonexistent"');
|
|
64
|
-
});
|
|
65
|
-
it("should throw for invalid docs path", () => {
|
|
66
|
-
setXanoscriptDocsPath("/nonexistent/path");
|
|
67
|
-
expect(() => xanoscriptDocs({ topic: "syntax" })).toThrow();
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe("xanoscriptDocsTool", () => {
|
|
71
|
-
it("should return success with data for valid call", () => {
|
|
72
|
-
const result = xanoscriptDocsTool();
|
|
73
|
-
expect(result.success).toBe(true);
|
|
74
|
-
expect(result.data).toBeDefined();
|
|
75
|
-
expect(typeof result.data).toBe("string");
|
|
76
|
-
expect(result.error).toBeUndefined();
|
|
77
|
-
});
|
|
78
|
-
it("should return success with topic docs", () => {
|
|
79
|
-
const result = xanoscriptDocsTool({ topic: "syntax" });
|
|
80
|
-
expect(result.success).toBe(true);
|
|
81
|
-
expect(result.data).toContain("Documentation version:");
|
|
82
|
-
});
|
|
83
|
-
it("should return error for unknown topic", () => {
|
|
84
|
-
const result = xanoscriptDocsTool({ topic: "nonexistent" });
|
|
85
|
-
expect(result.success).toBe(false);
|
|
86
|
-
expect(result.error).toBeDefined();
|
|
87
|
-
expect(result.error).toContain("Unknown topic");
|
|
88
|
-
});
|
|
89
|
-
it("should return error for invalid docs path", () => {
|
|
90
|
-
setXanoscriptDocsPath("/nonexistent/path");
|
|
91
|
-
const result = xanoscriptDocsTool({ topic: "syntax" });
|
|
92
|
-
expect(result.success).toBe(false);
|
|
93
|
-
expect(result.error).toBeDefined();
|
|
94
|
-
expect(result.error).toContain("Error retrieving XanoScript documentation");
|
|
95
|
-
});
|
|
96
|
-
it("should return multi-content array for file_path mode", () => {
|
|
97
|
-
const result = xanoscriptDocsTool({ file_path: "api/users/create.xs" });
|
|
98
|
-
expect(result.success).toBe(true);
|
|
99
|
-
expect(Array.isArray(result.data)).toBe(true);
|
|
100
|
-
const data = result.data;
|
|
101
|
-
// First element is the header
|
|
102
|
-
expect(data[0]).toContain("XanoScript Documentation for: api/users/create.xs");
|
|
103
|
-
expect(data[0]).toContain("Matched topics:");
|
|
104
|
-
expect(data[0]).toContain("Version:");
|
|
105
|
-
// Remaining elements are per-topic content
|
|
106
|
-
expect(data.length).toBeGreaterThan(1);
|
|
107
|
-
});
|
|
108
|
-
it("should return single string for topic mode", () => {
|
|
109
|
-
const result = xanoscriptDocsTool({ topic: "syntax" });
|
|
110
|
-
expect(result.success).toBe(true);
|
|
111
|
-
expect(typeof result.data).toBe("string");
|
|
112
|
-
expect(Array.isArray(result.data)).toBe(false);
|
|
113
|
-
});
|
|
114
|
-
it("should return single string for no-args mode", () => {
|
|
115
|
-
const result = xanoscriptDocsTool();
|
|
116
|
-
expect(result.success).toBe(true);
|
|
117
|
-
expect(typeof result.data).toBe("string");
|
|
118
|
-
expect(Array.isArray(result.data)).toBe(false);
|
|
119
|
-
});
|
|
120
|
-
it("should produce multiple MCP content blocks for file_path via toMcpResponse", () => {
|
|
121
|
-
const result = xanoscriptDocsTool({ file_path: "api/users/create.xs" });
|
|
122
|
-
const mcpResponse = toMcpResponse(result);
|
|
123
|
-
expect(mcpResponse.isError).toBeUndefined();
|
|
124
|
-
// Should have multiple content blocks (header + N topics)
|
|
125
|
-
expect(mcpResponse.content.length).toBeGreaterThan(1);
|
|
126
|
-
// All blocks should be text type
|
|
127
|
-
for (const block of mcpResponse.content) {
|
|
128
|
-
expect(block.type).toBe("text");
|
|
129
|
-
expect(typeof block.text).toBe("string");
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
it("should produce single MCP content block for topic mode via toMcpResponse", () => {
|
|
133
|
-
const result = xanoscriptDocsTool({ topic: "syntax" });
|
|
134
|
-
const mcpResponse = toMcpResponse(result);
|
|
135
|
-
expect(mcpResponse.content).toHaveLength(1);
|
|
136
|
-
expect(mcpResponse.content[0].type).toBe("text");
|
|
137
|
-
});
|
|
138
|
-
it("should include structuredContent for file_path mode", () => {
|
|
139
|
-
const result = xanoscriptDocsTool({ file_path: "api/users/create.xs" });
|
|
140
|
-
expect(result.success).toBe(true);
|
|
141
|
-
expect(result.structuredContent).toBeDefined();
|
|
142
|
-
expect(result.structuredContent).toHaveProperty("file_path", "api/users/create.xs");
|
|
143
|
-
expect(result.structuredContent).toHaveProperty("mode", "quick_reference");
|
|
144
|
-
expect(result.structuredContent).toHaveProperty("version");
|
|
145
|
-
expect(result.structuredContent).toHaveProperty("topics");
|
|
146
|
-
expect(Array.isArray(result.structuredContent.topics)).toBe(true);
|
|
147
|
-
});
|
|
148
|
-
it("should include structuredContent for topic mode", () => {
|
|
149
|
-
const result = xanoscriptDocsTool({ topic: "syntax" });
|
|
150
|
-
expect(result.success).toBe(true);
|
|
151
|
-
expect(result.structuredContent).toBeDefined();
|
|
152
|
-
expect(result.structuredContent).toHaveProperty("documentation");
|
|
153
|
-
});
|
|
154
|
-
it("should include structuredContent in MCP response", () => {
|
|
155
|
-
const result = xanoscriptDocsTool({ file_path: "api/users/create.xs" });
|
|
156
|
-
const mcpResponse = toMcpResponse(result);
|
|
157
|
-
expect(mcpResponse.structuredContent).toBeDefined();
|
|
158
|
-
expect(mcpResponse.structuredContent).toHaveProperty("file_path");
|
|
159
|
-
expect(mcpResponse.structuredContent).toHaveProperty("topics");
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
describe("xanoscriptDocs structured output", () => {
|
|
163
|
-
it("should include topics array for file_path mode", () => {
|
|
164
|
-
const result = xanoscriptDocs({ file_path: "api/users/create.xs" });
|
|
165
|
-
expect(result.topics).toBeDefined();
|
|
166
|
-
expect(Array.isArray(result.topics)).toBe(true);
|
|
167
|
-
expect(result.topics.length).toBeGreaterThan(0);
|
|
168
|
-
});
|
|
169
|
-
it("should have topic and content fields in each TopicDoc", () => {
|
|
170
|
-
const result = xanoscriptDocs({ file_path: "api/users/create.xs" });
|
|
171
|
-
for (const doc of result.topics) {
|
|
172
|
-
expect(doc).toHaveProperty("topic");
|
|
173
|
-
expect(doc).toHaveProperty("content");
|
|
174
|
-
expect(typeof doc.topic).toBe("string");
|
|
175
|
-
expect(typeof doc.content).toBe("string");
|
|
176
|
-
expect(doc.content.length).toBeGreaterThan(0);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
it("should not include topics array for topic mode", () => {
|
|
180
|
-
const result = xanoscriptDocs({ topic: "syntax" });
|
|
181
|
-
expect(result.topics).toBeUndefined();
|
|
182
|
-
});
|
|
183
|
-
it("should not include topics array for no-args mode", () => {
|
|
184
|
-
const result = xanoscriptDocs();
|
|
185
|
-
expect(result.topics).toBeUndefined();
|
|
186
|
-
});
|
|
187
|
-
it("should respect exclude_topics in structured output", () => {
|
|
188
|
-
const result = xanoscriptDocs({
|
|
189
|
-
file_path: "api/users/create.xs",
|
|
190
|
-
exclude_topics: ["syntax", "essentials"],
|
|
191
|
-
});
|
|
192
|
-
expect(result.topics).toBeDefined();
|
|
193
|
-
const topicNames = result.topics.map((d) => d.topic);
|
|
194
|
-
expect(topicNames).not.toContain("syntax");
|
|
195
|
-
expect(topicNames).not.toContain("essentials");
|
|
196
|
-
});
|
|
197
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|