@tanstack/cli 0.60.0 → 0.61.1
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/CHANGELOG.md +35 -0
- package/dist/cli.js +266 -11
- package/dist/command-line.js +103 -8
- package/dist/discovery.js +144 -0
- package/dist/options.js +35 -2
- package/dist/types/command-line.d.ts +7 -0
- package/dist/types/{mcp/types.d.ts → discovery.d.ts} +23 -75
- package/dist/types/types.d.ts +1 -2
- package/dist/types/ui-prompts.d.ts +5 -0
- package/dist/ui-prompts.js +26 -0
- package/package.json +2 -5
- package/playwright-report/index.html +1 -1
- package/src/cli.ts +345 -13
- package/src/command-line.ts +147 -8
- package/src/discovery.ts +209 -0
- package/src/options.ts +46 -0
- package/src/types.ts +1 -2
- package/src/ui-prompts.ts +32 -0
- package/tests/command-line.test.ts +81 -0
- package/tests/options.test.ts +65 -0
- package/tests/ui-prompts.test.ts +28 -0
- package/tests-e2e/create-smoke.spec.ts +12 -12
- package/tests-e2e/router-only-smoke.spec.ts +11 -25
- package/tests-e2e/solid-smoke.spec.ts +3 -2
- package/dist/mcp/api.js +0 -31
- package/dist/mcp/tools.js +0 -250
- package/dist/mcp/types.js +0 -37
- package/dist/mcp.js +0 -181
- package/dist/types/mcp/api.d.ts +0 -4
- package/dist/types/mcp/tools.d.ts +0 -2
- package/dist/types/mcp.d.ts +0 -5
- package/src/mcp/api.ts +0 -42
- package/src/mcp/tools.ts +0 -323
- package/src/mcp/types.ts +0 -46
- package/src/mcp.ts +0 -263
- package/tests/mcp.test.ts +0 -225
package/tests/mcp.test.ts
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
3
|
-
import { registerDocTools } from '../src/mcp/tools.js'
|
|
4
|
-
import * as api from '../src/mcp/api.js'
|
|
5
|
-
|
|
6
|
-
vi.mock('../src/mcp/api.js')
|
|
7
|
-
|
|
8
|
-
const mockLibrariesResponse = {
|
|
9
|
-
libraries: [
|
|
10
|
-
{
|
|
11
|
-
id: 'query',
|
|
12
|
-
name: 'TanStack Query',
|
|
13
|
-
tagline: 'Powerful asynchronous state management',
|
|
14
|
-
description: 'Data fetching library',
|
|
15
|
-
frameworks: ['react', 'vue', 'solid'],
|
|
16
|
-
latestVersion: 'v5',
|
|
17
|
-
latestBranch: 'main',
|
|
18
|
-
availableVersions: ['v5', 'v4'],
|
|
19
|
-
docsUrl: 'https://tanstack.com/query',
|
|
20
|
-
githubUrl: 'https://github.com/TanStack/query',
|
|
21
|
-
repo: 'TanStack/query',
|
|
22
|
-
docsRoot: 'docs',
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
id: 'router',
|
|
26
|
-
name: 'TanStack Router',
|
|
27
|
-
tagline: 'Type-safe routing',
|
|
28
|
-
description: 'Router library',
|
|
29
|
-
frameworks: ['react'],
|
|
30
|
-
latestVersion: 'v1',
|
|
31
|
-
latestBranch: 'main',
|
|
32
|
-
availableVersions: ['v1'],
|
|
33
|
-
docsUrl: 'https://tanstack.com/router',
|
|
34
|
-
githubUrl: 'https://github.com/TanStack/router',
|
|
35
|
-
repo: 'TanStack/router',
|
|
36
|
-
docsRoot: 'docs',
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
groups: {
|
|
40
|
-
state: ['query'],
|
|
41
|
-
headlessUI: [],
|
|
42
|
-
performance: [],
|
|
43
|
-
tooling: ['router'],
|
|
44
|
-
},
|
|
45
|
-
groupNames: {
|
|
46
|
-
state: 'State Management',
|
|
47
|
-
headlessUI: 'Headless UI',
|
|
48
|
-
performance: 'Performance',
|
|
49
|
-
tooling: 'Tooling',
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const mockPartnersResponse = {
|
|
54
|
-
partners: [
|
|
55
|
-
{
|
|
56
|
-
id: 'neon',
|
|
57
|
-
name: 'Neon',
|
|
58
|
-
description: 'Serverless Postgres',
|
|
59
|
-
category: 'database',
|
|
60
|
-
categoryLabel: 'Database',
|
|
61
|
-
libraries: ['start', 'router'],
|
|
62
|
-
url: 'https://neon.tech',
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
categories: ['database', 'auth'],
|
|
66
|
-
categoryLabels: {
|
|
67
|
-
database: 'Database',
|
|
68
|
-
auth: 'Authentication',
|
|
69
|
-
},
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
describe('MCP Tools', () => {
|
|
73
|
-
let server: McpServer
|
|
74
|
-
let registeredTools: Map<string, { handler: Function; schema: unknown }>
|
|
75
|
-
|
|
76
|
-
beforeEach(() => {
|
|
77
|
-
vi.resetAllMocks()
|
|
78
|
-
|
|
79
|
-
// Create a mock server that captures tool registrations
|
|
80
|
-
registeredTools = new Map()
|
|
81
|
-
server = {
|
|
82
|
-
tool: vi.fn((name, description, schema, handler) => {
|
|
83
|
-
registeredTools.set(name, { handler, schema })
|
|
84
|
-
}),
|
|
85
|
-
} as unknown as McpServer
|
|
86
|
-
|
|
87
|
-
vi.mocked(api.fetchLibraries).mockResolvedValue(mockLibrariesResponse)
|
|
88
|
-
vi.mocked(api.fetchPartners).mockResolvedValue(mockPartnersResponse)
|
|
89
|
-
vi.mocked(api.fetchDocContent).mockResolvedValue('# Test Doc\n\nContent here')
|
|
90
|
-
|
|
91
|
-
registerDocTools(server)
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
describe('tanstack_list_libraries', () => {
|
|
95
|
-
it('should register the tool', () => {
|
|
96
|
-
expect(registeredTools.has('tanstack_list_libraries')).toBe(true)
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
it('should list all libraries when no group specified', async () => {
|
|
100
|
-
const tool = registeredTools.get('tanstack_list_libraries')!
|
|
101
|
-
const result = await tool.handler({})
|
|
102
|
-
|
|
103
|
-
expect(result.content[0].type).toBe('text')
|
|
104
|
-
const data = JSON.parse(result.content[0].text)
|
|
105
|
-
expect(data.count).toBe(2)
|
|
106
|
-
expect(data.libraries).toHaveLength(2)
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
it('should filter libraries by group', async () => {
|
|
110
|
-
const tool = registeredTools.get('tanstack_list_libraries')!
|
|
111
|
-
const result = await tool.handler({ group: 'state' })
|
|
112
|
-
|
|
113
|
-
const data = JSON.parse(result.content[0].text)
|
|
114
|
-
expect(data.count).toBe(1)
|
|
115
|
-
expect(data.libraries[0].id).toBe('query')
|
|
116
|
-
expect(data.group).toBe('State Management')
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
it('should handle API errors', async () => {
|
|
120
|
-
vi.mocked(api.fetchLibraries).mockRejectedValue(new Error('Network error'))
|
|
121
|
-
|
|
122
|
-
const tool = registeredTools.get('tanstack_list_libraries')!
|
|
123
|
-
const result = await tool.handler({})
|
|
124
|
-
|
|
125
|
-
expect(result.isError).toBe(true)
|
|
126
|
-
expect(result.content[0].text).toContain('Error')
|
|
127
|
-
})
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
describe('tanstack_doc', () => {
|
|
131
|
-
it('should register the tool', () => {
|
|
132
|
-
expect(registeredTools.has('tanstack_doc')).toBe(true)
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
it('should fetch doc content', async () => {
|
|
136
|
-
const tool = registeredTools.get('tanstack_doc')!
|
|
137
|
-
const result = await tool.handler({
|
|
138
|
-
library: 'query',
|
|
139
|
-
path: 'framework/react/overview',
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
expect(api.fetchDocContent).toHaveBeenCalledWith(
|
|
143
|
-
'TanStack/query',
|
|
144
|
-
'main',
|
|
145
|
-
'docs/framework/react/overview.md',
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
const data = JSON.parse(result.content[0].text)
|
|
149
|
-
expect(data.content).toContain('# Test Doc')
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
it('should error for unknown library', async () => {
|
|
153
|
-
const tool = registeredTools.get('tanstack_doc')!
|
|
154
|
-
const result = await tool.handler({
|
|
155
|
-
library: 'unknown',
|
|
156
|
-
path: 'overview',
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
expect(result.isError).toBe(true)
|
|
160
|
-
expect(result.content[0].text).toContain('not found')
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
it('should error for unknown version', async () => {
|
|
164
|
-
const tool = registeredTools.get('tanstack_doc')!
|
|
165
|
-
const result = await tool.handler({
|
|
166
|
-
library: 'query',
|
|
167
|
-
path: 'overview',
|
|
168
|
-
version: 'v999',
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
expect(result.isError).toBe(true)
|
|
172
|
-
expect(result.content[0].text).toContain('Version')
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
it('should handle 404 doc', async () => {
|
|
176
|
-
vi.mocked(api.fetchDocContent).mockResolvedValue(null)
|
|
177
|
-
|
|
178
|
-
const tool = registeredTools.get('tanstack_doc')!
|
|
179
|
-
const result = await tool.handler({
|
|
180
|
-
library: 'query',
|
|
181
|
-
path: 'nonexistent',
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
expect(result.isError).toBe(true)
|
|
185
|
-
expect(result.content[0].text).toContain('not found')
|
|
186
|
-
})
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
describe('tanstack_ecosystem', () => {
|
|
190
|
-
it('should register the tool', () => {
|
|
191
|
-
expect(registeredTools.has('tanstack_ecosystem')).toBe(true)
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
it('should list ecosystem partners', async () => {
|
|
195
|
-
const tool = registeredTools.get('tanstack_ecosystem')!
|
|
196
|
-
const result = await tool.handler({})
|
|
197
|
-
|
|
198
|
-
const data = JSON.parse(result.content[0].text)
|
|
199
|
-
expect(data.partners).toHaveLength(1)
|
|
200
|
-
expect(data.partners[0].id).toBe('neon')
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
it('should filter by category', async () => {
|
|
204
|
-
const tool = registeredTools.get('tanstack_ecosystem')!
|
|
205
|
-
const result = await tool.handler({ category: 'database' })
|
|
206
|
-
|
|
207
|
-
const data = JSON.parse(result.content[0].text)
|
|
208
|
-
expect(data.partners).toHaveLength(1)
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
it('should filter by library', async () => {
|
|
212
|
-
const tool = registeredTools.get('tanstack_ecosystem')!
|
|
213
|
-
const result = await tool.handler({ library: 'start' })
|
|
214
|
-
|
|
215
|
-
const data = JSON.parse(result.content[0].text)
|
|
216
|
-
expect(data.partners).toHaveLength(1)
|
|
217
|
-
})
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
describe('tanstack_search_docs', () => {
|
|
221
|
-
it('should register the tool', () => {
|
|
222
|
-
expect(registeredTools.has('tanstack_search_docs')).toBe(true)
|
|
223
|
-
})
|
|
224
|
-
})
|
|
225
|
-
})
|