@auracheck-ai/cli 0.0.0-stage → 0.2.2
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 +195 -2
- package/USAGE.md +117 -0
- package/dist/api.js +433 -0
- package/dist/api.js.map +1 -0
- package/dist/bin.js +152 -0
- package/dist/bin.js.map +1 -0
- package/dist/browser-login.js +130 -0
- package/dist/browser-login.js.map +1 -0
- package/dist/commands/doctor.js +90 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.js +101 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/login.js +132 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/setup.js +188 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/status.js +36 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/config.js +275 -0
- package/dist/config.js.map +1 -0
- package/dist/mcp/server.js +942 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/source-reader.js +200 -0
- package/dist/source-reader.js.map +1 -0
- package/package.json +61 -4
|
@@ -0,0 +1,942 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { setTimeout as sleep } from 'node:timers/promises';
|
|
3
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
4
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { ApiError, SixSevenApi, TERMINAL_RUN_STATUSES, } from '../api.js';
|
|
8
|
+
import { DEFAULT_EXCLUDE, getToken, resolveContext, } from '../config.js';
|
|
9
|
+
import { SourceReader } from '../source-reader.js';
|
|
10
|
+
const { version: CLI_VERSION } = createRequire(import.meta.url)('../../package.json');
|
|
11
|
+
const tools = [
|
|
12
|
+
// ---------- Whitebox: source code ----------
|
|
13
|
+
{
|
|
14
|
+
name: 'sixseven.read_code',
|
|
15
|
+
description: 'Read a text file from the developer repo. Path is relative to repo root and must fall within configured codeRoots. Use to understand routes, components, validators, and fixtures before generating a testcase.',
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: { path: { type: 'string' } },
|
|
19
|
+
required: ['path'],
|
|
20
|
+
},
|
|
21
|
+
zod: z.object({ path: z.string().min(1) }),
|
|
22
|
+
handler: async ({ path }, { reader }) => reader.readFile(path),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'sixseven.list_dir',
|
|
26
|
+
description: 'List entries of a directory inside the developer repo. Path is relative to repo root.',
|
|
27
|
+
inputSchema: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: { path: { type: 'string', default: '.' } },
|
|
30
|
+
},
|
|
31
|
+
zod: z.object({ path: z.string().default('.') }),
|
|
32
|
+
handler: async ({ path }, { reader }) => reader.listDir(path),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'sixseven.search_code',
|
|
36
|
+
description: 'Search developer repo (within codeRoots) for a substring or regex. Returns up to 200 matches with file + line + preview. Use to locate routes, handlers, components by name.',
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
query: { type: 'string' },
|
|
41
|
+
regex: { type: 'boolean', default: false },
|
|
42
|
+
caseSensitive: { type: 'boolean', default: false },
|
|
43
|
+
maxResults: { type: 'number', default: 200 },
|
|
44
|
+
},
|
|
45
|
+
required: ['query'],
|
|
46
|
+
},
|
|
47
|
+
zod: z.object({
|
|
48
|
+
query: z.string().min(1),
|
|
49
|
+
regex: z.boolean().optional(),
|
|
50
|
+
caseSensitive: z.boolean().optional(),
|
|
51
|
+
maxResults: z.number().int().positive().max(1000).optional(),
|
|
52
|
+
}),
|
|
53
|
+
handler: async (args, { reader }) => reader.search(args.query, args),
|
|
54
|
+
},
|
|
55
|
+
// ---------- SixSeven: projects ----------
|
|
56
|
+
{
|
|
57
|
+
name: 'sixseven.list_projects',
|
|
58
|
+
description: 'List the AuraCheck projects this sign-in can reach (id, name, platforms, defaultConfigurationId). Pass a project id as `projectId` to any project tool to work outside the repo-bound project.',
|
|
59
|
+
inputSchema: { type: 'object', properties: {} },
|
|
60
|
+
zod: z.object({}).passthrough(),
|
|
61
|
+
handler: async (_args, { api }) => {
|
|
62
|
+
const projects = await api.listProjects();
|
|
63
|
+
return projects.map((p) => ({
|
|
64
|
+
id: p.id,
|
|
65
|
+
name: p.name,
|
|
66
|
+
companyId: p.companyId,
|
|
67
|
+
platforms: p.platforms,
|
|
68
|
+
defaultConfigurationId: p.defaultConfigurationId ?? null,
|
|
69
|
+
}));
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
// ---------- SixSeven: features ----------
|
|
73
|
+
{
|
|
74
|
+
name: 'sixseven.list_features',
|
|
75
|
+
description: 'List features (groups of testcases) for the bound SixSeven project. Each feature has an id and a name. Pick the most relevant feature id before creating a testcase.',
|
|
76
|
+
inputSchema: { type: 'object', properties: {} },
|
|
77
|
+
zod: z.object({}).passthrough(),
|
|
78
|
+
handler: async (_args, { api, projectId }) => api.listFeatures(projectId),
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'sixseven.create_feature',
|
|
82
|
+
description: 'Create a new feature in the bound SixSeven project. Use when no existing feature fits the testcase you are about to create.',
|
|
83
|
+
inputSchema: {
|
|
84
|
+
type: 'object',
|
|
85
|
+
properties: {
|
|
86
|
+
name: { type: 'string' },
|
|
87
|
+
path: { type: 'string' },
|
|
88
|
+
description: { type: 'string' },
|
|
89
|
+
prdContent: { type: 'string' },
|
|
90
|
+
},
|
|
91
|
+
required: ['name'],
|
|
92
|
+
},
|
|
93
|
+
zod: z.object({
|
|
94
|
+
name: z.string().min(1),
|
|
95
|
+
path: z.string().optional(),
|
|
96
|
+
description: z.string().optional(),
|
|
97
|
+
prdContent: z.string().optional(),
|
|
98
|
+
}),
|
|
99
|
+
handler: async (args, { api, projectId }) => api.createFeature(projectId, args),
|
|
100
|
+
},
|
|
101
|
+
// ---------- SixSeven: testcases ----------
|
|
102
|
+
{
|
|
103
|
+
name: 'sixseven.list_testcases',
|
|
104
|
+
description: 'List testcases for the bound SixSeven project, optionally filtered by platform (web/android/ios).',
|
|
105
|
+
inputSchema: {
|
|
106
|
+
type: 'object',
|
|
107
|
+
properties: {
|
|
108
|
+
platform: { type: 'string', enum: ['web', 'android', 'ios'] },
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
zod: z.object({ platform: z.enum(['web', 'android', 'ios']).optional() }),
|
|
112
|
+
handler: async (args, { api, projectId }) => api.listTestCasesByProject(projectId, args.platform),
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'sixseven.get_testcase',
|
|
116
|
+
description: 'Fetch a single testcase by id. `steps` comes back as the Midscene YAML/JSON string the server stores, not an array — parse it before editing, and pass it back through sixseven.update_testcase in either form.',
|
|
117
|
+
inputSchema: {
|
|
118
|
+
type: 'object',
|
|
119
|
+
properties: { id: { type: 'string' } },
|
|
120
|
+
required: ['id'],
|
|
121
|
+
},
|
|
122
|
+
zod: z.object({ id: z.string().min(1) }),
|
|
123
|
+
handler: async ({ id }, { api, projectId }) => api.getTestCase(id, projectId),
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: 'sixseven.create_testcase',
|
|
127
|
+
description: 'Create a new testcase under a SixSeven feature. `steps` is the Midscene flow: pass EITHER an array of flow items (each item is one action, e.g. { aiTap: "Sign in" }, { aiInput: "user@example.com", locate: "Email field" }, { aiAssert: "Dashboard is visible" }) OR a YAML/JSON string already shaped as `tasks: [{ name, flow: [...] }]`. Recognized action keys: aiTap, aiInput, aiAssert, aiQuery, aiHover, aiWaitFor, aiKeyboardPress, aiScroll, aiAction, sleep, javascript, aiUploadFile, aiHumanInput, aiExpectDownload, mailTmInbox, mailTmWaitOtp, mailTmWaitLink, otpInbox, otpWaitOtp. A bare array is auto-wrapped into the required tasks[] structure. If featureId is omitted, the project default from .sixseven/config.json is used.',
|
|
128
|
+
inputSchema: {
|
|
129
|
+
type: 'object',
|
|
130
|
+
properties: {
|
|
131
|
+
featureId: { type: 'string' },
|
|
132
|
+
name: { type: 'string' },
|
|
133
|
+
steps: {
|
|
134
|
+
description: 'Array of Midscene flow items (auto-wrapped into tasks[]), or a YAML/JSON string shaped as `tasks: [{ name, flow: [...] }]`.',
|
|
135
|
+
oneOf: [
|
|
136
|
+
{ type: 'array', items: { type: 'object' } },
|
|
137
|
+
{ type: 'string' },
|
|
138
|
+
{ type: 'object' },
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
executionType: {
|
|
142
|
+
type: 'string',
|
|
143
|
+
enum: ['automation', 'manual'],
|
|
144
|
+
default: 'automation',
|
|
145
|
+
description: 'Whether the automation job runs this case or a human does. Manual cases are excluded from automation runs. Defaults to "automation".',
|
|
146
|
+
},
|
|
147
|
+
priority: {
|
|
148
|
+
type: 'string',
|
|
149
|
+
enum: ['low', 'medium', 'high', 'critical'],
|
|
150
|
+
default: 'medium',
|
|
151
|
+
},
|
|
152
|
+
category: { type: 'string', default: 'positive' },
|
|
153
|
+
reason: { type: 'string' },
|
|
154
|
+
description: { type: 'string' },
|
|
155
|
+
expectedResult: { type: 'string' },
|
|
156
|
+
platforms: { type: 'array', items: { type: 'string' } },
|
|
157
|
+
coveredScenarios: { type: 'array', items: { type: 'string' } },
|
|
158
|
+
tags: { type: 'array', items: { type: 'string' } },
|
|
159
|
+
},
|
|
160
|
+
required: ['name', 'steps'],
|
|
161
|
+
},
|
|
162
|
+
zod: z.object({
|
|
163
|
+
featureId: z.string().optional(),
|
|
164
|
+
name: z.string().min(1),
|
|
165
|
+
steps: z.union([
|
|
166
|
+
z.array(z.record(z.any())).min(1),
|
|
167
|
+
z.string().min(1),
|
|
168
|
+
z.record(z.any()),
|
|
169
|
+
]),
|
|
170
|
+
executionType: z.enum(['automation', 'manual']).default('automation'),
|
|
171
|
+
priority: z.enum(['low', 'medium', 'high', 'critical']).optional(),
|
|
172
|
+
category: z.string().optional(),
|
|
173
|
+
reason: z.string().optional(),
|
|
174
|
+
description: z.string().optional(),
|
|
175
|
+
expectedResult: z.string().optional(),
|
|
176
|
+
platforms: z.array(z.string()).optional(),
|
|
177
|
+
coveredScenarios: z.array(z.string()).optional(),
|
|
178
|
+
tags: z.array(z.string()).optional(),
|
|
179
|
+
}),
|
|
180
|
+
handler: async (args, { api, defaultFeatureId }) => {
|
|
181
|
+
const featureId = args.featureId ?? defaultFeatureId;
|
|
182
|
+
if (!featureId) {
|
|
183
|
+
throw new Error('No featureId provided and no defaultFeatureId in .sixseven/config.json. Call sixseven.list_features or sixseven.create_feature first.');
|
|
184
|
+
}
|
|
185
|
+
const { featureId: _ignore, ...payload } = args;
|
|
186
|
+
return api.createTestCase(featureId, payload);
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: 'sixseven.update_testcase',
|
|
191
|
+
description: 'Patch an existing testcase — only the fields you pass are touched. Useful in the auto-fix loop after reading evidence from a failed run. A `steps` patch accepts the same shapes as sixseven.create_testcase (flow array, or YAML/JSON string with tasks[]).',
|
|
192
|
+
inputSchema: {
|
|
193
|
+
type: 'object',
|
|
194
|
+
properties: {
|
|
195
|
+
id: { type: 'string' },
|
|
196
|
+
patch: { type: 'object' },
|
|
197
|
+
},
|
|
198
|
+
required: ['id', 'patch'],
|
|
199
|
+
},
|
|
200
|
+
zod: z.object({ id: z.string().min(1), patch: z.record(z.any()) }),
|
|
201
|
+
handler: async ({ id, patch }, { api }) => api.updateTestCase(id, patch),
|
|
202
|
+
},
|
|
203
|
+
// ---------- SixSeven: runs ----------
|
|
204
|
+
{
|
|
205
|
+
name: 'sixseven.list_runs',
|
|
206
|
+
description: 'List recent runs for the bound SixSeven project, optionally filtered by platform.',
|
|
207
|
+
inputSchema: {
|
|
208
|
+
type: 'object',
|
|
209
|
+
properties: {
|
|
210
|
+
platform: { type: 'string', enum: ['web', 'android', 'ios'] },
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
zod: z.object({ platform: z.enum(['web', 'android', 'ios']).optional() }),
|
|
214
|
+
handler: async (args, { api, projectId }) => api.listRuns(projectId, args.platform),
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: 'sixseven.get_run',
|
|
218
|
+
description: 'Fetch a single run by id including current status, started/completed timestamps, and reportUrl when available.',
|
|
219
|
+
inputSchema: {
|
|
220
|
+
type: 'object',
|
|
221
|
+
properties: { runId: { type: 'string' } },
|
|
222
|
+
required: ['runId'],
|
|
223
|
+
},
|
|
224
|
+
zod: z.object({ runId: z.string().min(1) }),
|
|
225
|
+
handler: async ({ runId }, { api }) => api.getRun(runId),
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: 'sixseven.get_run_report',
|
|
229
|
+
description: 'Results of a run as the Run Report groups them: case counts (passed/failed/skipped/pending) plus buckets — potential bugs (with bug report, severity), script issues, blocked cases and passed cases. Read-only.',
|
|
230
|
+
inputSchema: {
|
|
231
|
+
type: 'object',
|
|
232
|
+
properties: { runId: { type: 'string' } },
|
|
233
|
+
required: ['runId'],
|
|
234
|
+
},
|
|
235
|
+
zod: z.object({ runId: z.string().min(1) }),
|
|
236
|
+
handler: async ({ runId }, { api }) => {
|
|
237
|
+
const [run, counts, buckets] = await Promise.all([
|
|
238
|
+
api.getRun(runId),
|
|
239
|
+
api.getRunCaseStatusCounts(runId),
|
|
240
|
+
api.getRunReportBuckets(runId),
|
|
241
|
+
]);
|
|
242
|
+
return {
|
|
243
|
+
run: {
|
|
244
|
+
id: run.id,
|
|
245
|
+
name: run.name,
|
|
246
|
+
status: run.status,
|
|
247
|
+
reportUrl: run.reportUrl ?? null,
|
|
248
|
+
},
|
|
249
|
+
counts,
|
|
250
|
+
...buckets,
|
|
251
|
+
};
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: 'sixseven.create_run',
|
|
256
|
+
description: 'Create a new run for one or more testcases. Defaults: caseSelectionMode="select", platform from .sixseven/config.json. Returns the created run object including its id.',
|
|
257
|
+
inputSchema: {
|
|
258
|
+
type: 'object',
|
|
259
|
+
properties: {
|
|
260
|
+
name: { type: 'string' },
|
|
261
|
+
testCaseIds: { type: 'array', items: { type: 'string' } },
|
|
262
|
+
featureIds: { type: 'array', items: { type: 'string' } },
|
|
263
|
+
platform: { type: 'string', enum: ['web', 'android', 'ios'] },
|
|
264
|
+
caseSelectionMode: { type: 'string', enum: ['all', 'select'] },
|
|
265
|
+
configurationId: { type: 'string' },
|
|
266
|
+
milestoneId: { type: 'string' },
|
|
267
|
+
tags: { type: 'array', items: { type: 'string' } },
|
|
268
|
+
notes: { type: 'string' },
|
|
269
|
+
browserEngine: {
|
|
270
|
+
type: 'string',
|
|
271
|
+
enum: ['chrome', 'edge'],
|
|
272
|
+
description: 'Leave unset: the cloud runner ships its own Chromium; chrome/edge only work on runners that have that browser installed.',
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
required: ['name'],
|
|
276
|
+
},
|
|
277
|
+
zod: z.object({
|
|
278
|
+
name: z.string().min(1),
|
|
279
|
+
testCaseIds: z.array(z.string()).optional(),
|
|
280
|
+
featureIds: z.array(z.string()).optional(),
|
|
281
|
+
platform: z.enum(['web', 'android', 'ios']).optional(),
|
|
282
|
+
caseSelectionMode: z.enum(['all', 'select']).optional(),
|
|
283
|
+
configurationId: z.string().optional(),
|
|
284
|
+
milestoneId: z.string().optional(),
|
|
285
|
+
tags: z.array(z.string()).optional(),
|
|
286
|
+
notes: z.string().optional(),
|
|
287
|
+
browserEngine: z.enum(['chrome', 'edge']).optional(),
|
|
288
|
+
}),
|
|
289
|
+
handler: async (args, { api, projectId, defaultPlatform }) => {
|
|
290
|
+
const body = {
|
|
291
|
+
...args,
|
|
292
|
+
platform: args.platform ?? defaultPlatform,
|
|
293
|
+
caseSelectionMode: args.caseSelectionMode ??
|
|
294
|
+
(args.testCaseIds?.length ? 'select' : 'all'),
|
|
295
|
+
};
|
|
296
|
+
return api.createRun(projectId, body);
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: 'sixseven.execute_run',
|
|
301
|
+
description: 'Trigger execution of an existing run. Fire-and-forget (202): the runner state lives in SixSeven. Use sixseven.wait_for_run to await terminal status.',
|
|
302
|
+
inputSchema: {
|
|
303
|
+
type: 'object',
|
|
304
|
+
properties: {
|
|
305
|
+
runId: { type: 'string' },
|
|
306
|
+
},
|
|
307
|
+
required: ['runId'],
|
|
308
|
+
},
|
|
309
|
+
zod: z.object({
|
|
310
|
+
runId: z.string().min(1),
|
|
311
|
+
}),
|
|
312
|
+
handler: async ({ runId }, { api }) => api.executeRun(runId),
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
name: 'sixseven.cancel_run',
|
|
316
|
+
description: 'Cancel an in-flight run. Idempotent for queued runs; for inline runs the cancel may take effect at the next case boundary.',
|
|
317
|
+
inputSchema: {
|
|
318
|
+
type: 'object',
|
|
319
|
+
properties: { runId: { type: 'string' } },
|
|
320
|
+
required: ['runId'],
|
|
321
|
+
},
|
|
322
|
+
zod: z.object({ runId: z.string().min(1) }),
|
|
323
|
+
handler: async ({ runId }, { api }) => api.cancelRun(runId),
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
name: 'sixseven.wait_for_run',
|
|
327
|
+
description: 'Poll a run until it reaches a terminal status (passed/failed/cancelled/error) or the timeout elapses. Returns the final run object plus a summary of per-case statuses. Default timeout 300 s, poll interval 3 s.',
|
|
328
|
+
inputSchema: {
|
|
329
|
+
type: 'object',
|
|
330
|
+
properties: {
|
|
331
|
+
runId: { type: 'string' },
|
|
332
|
+
timeoutSec: { type: 'number', default: 300 },
|
|
333
|
+
pollMs: { type: 'number', default: 3000 },
|
|
334
|
+
},
|
|
335
|
+
required: ['runId'],
|
|
336
|
+
},
|
|
337
|
+
zod: z.object({
|
|
338
|
+
runId: z.string().min(1),
|
|
339
|
+
timeoutSec: z.number().int().positive().max(3600).optional(),
|
|
340
|
+
pollMs: z.number().int().positive().max(30_000).optional(),
|
|
341
|
+
}),
|
|
342
|
+
handler: async (args, { api, baseUrl }) => {
|
|
343
|
+
const timeoutMs = (args.timeoutSec ?? 300) * 1000;
|
|
344
|
+
const pollMs = args.pollMs ?? 3000;
|
|
345
|
+
const start = Date.now();
|
|
346
|
+
let last = await api.getRun(args.runId);
|
|
347
|
+
while (!TERMINAL_RUN_STATUSES.has(last.status) &&
|
|
348
|
+
Date.now() - start < timeoutMs) {
|
|
349
|
+
await sleep(pollMs);
|
|
350
|
+
last = await api.getRun(args.runId);
|
|
351
|
+
}
|
|
352
|
+
const terminal = TERMINAL_RUN_STATUSES.has(last.status);
|
|
353
|
+
const attempts = await api
|
|
354
|
+
.listRunCaseAttempts(args.runId)
|
|
355
|
+
.catch(() => ({ attempts: [] }));
|
|
356
|
+
const summary = attempts.attempts.reduce((acc, a) => {
|
|
357
|
+
acc[a.status] = (acc[a.status] ?? 0) + 1;
|
|
358
|
+
return acc;
|
|
359
|
+
}, {});
|
|
360
|
+
return {
|
|
361
|
+
terminal,
|
|
362
|
+
elapsedMs: Date.now() - start,
|
|
363
|
+
runId: args.runId,
|
|
364
|
+
status: last.status,
|
|
365
|
+
reportUrl: last.reportUrl ?? null,
|
|
366
|
+
viewUrl: `${baseUrl}/runs/${args.runId}`,
|
|
367
|
+
completedAt: last.completedAt ?? null,
|
|
368
|
+
caseStatusSummary: summary,
|
|
369
|
+
run: last,
|
|
370
|
+
};
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
name: 'sixseven.list_run_testcases',
|
|
375
|
+
description: 'List the testcases attached to a specific run.',
|
|
376
|
+
inputSchema: {
|
|
377
|
+
type: 'object',
|
|
378
|
+
properties: { runId: { type: 'string' } },
|
|
379
|
+
required: ['runId'],
|
|
380
|
+
},
|
|
381
|
+
zod: z.object({ runId: z.string().min(1) }),
|
|
382
|
+
handler: async ({ runId }, { api }) => api.listRunTestCases(runId),
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
name: 'sixseven.get_evidence',
|
|
386
|
+
description: 'Aggregate evidence for a finished (or in-progress) run: per-case attempts, latest step events, failed-step screenshots and error messages, and the SixSeven report URL. A failed step that hung (tripped the per-step watchdog) also carries stallDiagnostics — a captured process tree, host memory pressure, CDP probe results, and in-flight requests — so a renderer stall can be diagnosed here instead of by shelling into production. Filter by caseId to narrow scope. Use after sixseven.wait_for_run to diagnose failures.',
|
|
387
|
+
inputSchema: {
|
|
388
|
+
type: 'object',
|
|
389
|
+
properties: {
|
|
390
|
+
runId: { type: 'string' },
|
|
391
|
+
caseId: { type: 'string' },
|
|
392
|
+
maxEventsPerCase: { type: 'number', default: 20 },
|
|
393
|
+
},
|
|
394
|
+
required: ['runId'],
|
|
395
|
+
},
|
|
396
|
+
zod: z.object({
|
|
397
|
+
runId: z.string().min(1),
|
|
398
|
+
caseId: z.string().optional(),
|
|
399
|
+
maxEventsPerCase: z.number().int().positive().max(200).optional(),
|
|
400
|
+
}),
|
|
401
|
+
handler: async (args, { api, baseUrl }) => {
|
|
402
|
+
const max = args.maxEventsPerCase ?? 20;
|
|
403
|
+
const [run, attemptsResp, eventsResp, runCases] = await Promise.all([
|
|
404
|
+
api.getRun(args.runId),
|
|
405
|
+
api.listRunCaseAttempts(args.runId),
|
|
406
|
+
api.listRunStepEvents(args.runId, args.caseId),
|
|
407
|
+
api.listRunTestCases(args.runId).catch(() => []),
|
|
408
|
+
]);
|
|
409
|
+
const caseNameById = new Map(runCases.map((c) => [c.id, c.name]));
|
|
410
|
+
const allEvents = eventsResp.events ?? [];
|
|
411
|
+
const eventsByCase = new Map();
|
|
412
|
+
for (const e of allEvents) {
|
|
413
|
+
const key = e.testCaseId ?? '__unbound__';
|
|
414
|
+
if (args.caseId && key !== args.caseId)
|
|
415
|
+
continue;
|
|
416
|
+
const arr = eventsByCase.get(key) ?? [];
|
|
417
|
+
arr.push(e);
|
|
418
|
+
eventsByCase.set(key, arr);
|
|
419
|
+
}
|
|
420
|
+
const attempts = (attemptsResp.attempts ?? []).filter((a) => !args.caseId || a.testCaseId === args.caseId);
|
|
421
|
+
const cases = attempts.map((attempt) => {
|
|
422
|
+
const events = (eventsByCase.get(attempt.testCaseId) ?? [])
|
|
423
|
+
.slice()
|
|
424
|
+
.sort((a, b) => (a.stepIndex ?? 0) - (b.stepIndex ?? 0))
|
|
425
|
+
.slice(0, max);
|
|
426
|
+
const failedSteps = events.filter((e) => e.status === 'failed' || e.error);
|
|
427
|
+
return {
|
|
428
|
+
testCaseId: attempt.testCaseId,
|
|
429
|
+
testCaseName: caseNameById.get(attempt.testCaseId) ?? null,
|
|
430
|
+
attemptId: attempt.id,
|
|
431
|
+
attemptStatus: attempt.status,
|
|
432
|
+
attemptReportUrl: attempt.reportUrl ?? null,
|
|
433
|
+
startedAt: attempt.startedAt,
|
|
434
|
+
completedAt: attempt.completedAt,
|
|
435
|
+
stepEvents: events.map((e) => ({
|
|
436
|
+
stepIndex: e.stepIndex,
|
|
437
|
+
stepType: e.stepType,
|
|
438
|
+
stepPrompt: e.stepPrompt,
|
|
439
|
+
status: e.status,
|
|
440
|
+
durationMs: e.durationMs,
|
|
441
|
+
error: e.error,
|
|
442
|
+
screenshotUrl: e.screenshotUrl,
|
|
443
|
+
notes: e.notes,
|
|
444
|
+
})),
|
|
445
|
+
failedSteps: failedSteps.map((e) => ({
|
|
446
|
+
stepIndex: e.stepIndex,
|
|
447
|
+
stepType: e.stepType,
|
|
448
|
+
error: e.error,
|
|
449
|
+
screenshotUrl: e.screenshotUrl,
|
|
450
|
+
// Present only for a step that tripped the per-step watchdog —
|
|
451
|
+
// process tree / host pressure / CDP probes captured right
|
|
452
|
+
// before teardown. Lets a stall be diagnosed here instead of by
|
|
453
|
+
// SSH-ing into prod to grep an already-rotated container log.
|
|
454
|
+
stallDiagnostics: e.stallDiagnostics ?? null,
|
|
455
|
+
})),
|
|
456
|
+
};
|
|
457
|
+
});
|
|
458
|
+
return {
|
|
459
|
+
runId: args.runId,
|
|
460
|
+
status: run.status,
|
|
461
|
+
platform: run.platform,
|
|
462
|
+
reportUrl: run.reportUrl ?? null,
|
|
463
|
+
viewUrl: `${baseUrl}/runs/${args.runId}`,
|
|
464
|
+
cases,
|
|
465
|
+
totals: {
|
|
466
|
+
caseCount: cases.length,
|
|
467
|
+
failedCaseCount: cases.filter((c) => c.attemptStatus === 'failed')
|
|
468
|
+
.length,
|
|
469
|
+
failedStepCount: cases.reduce((n, c) => n + c.failedSteps.length, 0),
|
|
470
|
+
},
|
|
471
|
+
};
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
name: 'sixseven.get_screenshot',
|
|
476
|
+
description: "Download a run screenshot (or any authenticated blob) to a local file and return its path, so it can then be opened and looked at. Pass a `screenshotUrl` straight from sixseven.get_evidence — those are bare paths that cannot be fetched without the bound base URL and CI token, so this is the only way to actually SEE a step's screenshot. Reach for it whenever a failure's cause is visual: 'the page froze' is often disproved by two consecutive screenshots being identical, or by the page rendering fine with a control merely disabled.",
|
|
477
|
+
inputSchema: {
|
|
478
|
+
type: 'object',
|
|
479
|
+
properties: {
|
|
480
|
+
url: {
|
|
481
|
+
type: 'string',
|
|
482
|
+
description: "screenshotUrl from get_evidence, e.g. '/api/blob/screenshots/<runId>/<caseId>-step14.png'. An absolute URL is accepted only on the bound host.",
|
|
483
|
+
},
|
|
484
|
+
outPath: {
|
|
485
|
+
type: 'string',
|
|
486
|
+
description: 'Where to write it. Defaults to a temp file named after the blob.',
|
|
487
|
+
},
|
|
488
|
+
},
|
|
489
|
+
required: ['url'],
|
|
490
|
+
},
|
|
491
|
+
zod: z.object({
|
|
492
|
+
url: z.string().min(1),
|
|
493
|
+
outPath: z.string().optional(),
|
|
494
|
+
}),
|
|
495
|
+
handler: async (args, { api }) => {
|
|
496
|
+
const { tmpdir } = await import('node:os');
|
|
497
|
+
const path = await import('node:path');
|
|
498
|
+
// Name the temp file after the blob so several screenshots from one
|
|
499
|
+
// investigation stay tellable apart on disk.
|
|
500
|
+
const base = path.basename(args.url.split('?')[0] || '').replace(/[^\w.-]/g, '_') ||
|
|
501
|
+
'screenshot.png';
|
|
502
|
+
const dest = args.outPath ?? path.join(tmpdir(), `sixseven-${Date.now()}-${base}`);
|
|
503
|
+
const res = await api.downloadBlob(args.url, dest);
|
|
504
|
+
return {
|
|
505
|
+
...res,
|
|
506
|
+
hint: 'Open this path with your file-reading tool to view the image.',
|
|
507
|
+
};
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
// ---------- SixSeven: schedules (recurring runs) ----------
|
|
511
|
+
{
|
|
512
|
+
name: 'sixseven.list_schedules',
|
|
513
|
+
description: 'List the recurring run schedules of the bound SixSeven project. Each schedule carries its cron expressions, IANA timezone, computed nextFireAt (UTC), platform, case filter and notify recipients.',
|
|
514
|
+
inputSchema: { type: 'object', properties: {} },
|
|
515
|
+
zod: z.object({}).passthrough(),
|
|
516
|
+
handler: async (_args, { api, projectId }) => api.listSchedules(projectId),
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
name: 'sixseven.get_schedule',
|
|
520
|
+
description: 'Fetch a single schedule by id. Note lastFiredAt reflects CLOCK-driven fires only — sixseven.run_schedule_now deliberately leaves it untouched, so read sixseven.list_schedule_fires for the full history.',
|
|
521
|
+
inputSchema: {
|
|
522
|
+
type: 'object',
|
|
523
|
+
properties: { scheduleId: { type: 'string' } },
|
|
524
|
+
required: ['scheduleId'],
|
|
525
|
+
},
|
|
526
|
+
zod: z.object({ scheduleId: z.string().min(1) }),
|
|
527
|
+
handler: async ({ scheduleId }, { api }) => api.getSchedule(scheduleId),
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
name: 'sixseven.create_schedule',
|
|
531
|
+
description: "Create a recurring run schedule. cronExpressions is 5-field cron evaluated in `timezone` (IANA, e.g. 'Asia/Jakarta'); several expressions are allowed and the earliest upcoming occurrence wins. caseFilter picks what runs: { mode: 'all' } for every case on the platform, or { mode: 'feature', featureIds: [...] } to narrow (get ids from sixseven.list_features). notifyUserIds must come from sixseven.list_schedule_recipients. Cron and timezone are validated server-side — an invalid cadence is rejected, never silently accepted. Prefer enabled:false while testing, then enable once the cadence reads right.",
|
|
532
|
+
inputSchema: {
|
|
533
|
+
type: 'object',
|
|
534
|
+
properties: {
|
|
535
|
+
name: { type: 'string' },
|
|
536
|
+
cronExpressions: {
|
|
537
|
+
type: 'array',
|
|
538
|
+
items: { type: 'string' },
|
|
539
|
+
minItems: 1,
|
|
540
|
+
description: "5-field cron, e.g. ['0 9 * * 1-5'] for weekdays 09:00.",
|
|
541
|
+
},
|
|
542
|
+
timezone: {
|
|
543
|
+
type: 'string',
|
|
544
|
+
description: "IANA timezone the cron is evaluated in, e.g. 'Asia/Jakarta'.",
|
|
545
|
+
},
|
|
546
|
+
platform: { type: 'string', enum: ['web', 'android', 'ios'] },
|
|
547
|
+
enabled: { type: 'boolean', default: true },
|
|
548
|
+
configurationId: {
|
|
549
|
+
type: 'string',
|
|
550
|
+
description: 'Environment the runs execute against. Omit ONLY when the project has a default configuration — without either, every run this schedule creates starts with no base URL and fails at the first navigation.',
|
|
551
|
+
},
|
|
552
|
+
caseFilter: {
|
|
553
|
+
type: 'object',
|
|
554
|
+
properties: {
|
|
555
|
+
mode: { type: 'string', enum: ['all', 'feature'] },
|
|
556
|
+
featureIds: { type: 'array', items: { type: 'string' } },
|
|
557
|
+
},
|
|
558
|
+
required: ['mode'],
|
|
559
|
+
},
|
|
560
|
+
notifyUserIds: { type: 'array', items: { type: 'string' } },
|
|
561
|
+
misfireGraceMinutes: {
|
|
562
|
+
type: 'number',
|
|
563
|
+
description: 'How late a clock-driven occurrence may still fire before it is skipped as a misfire.',
|
|
564
|
+
},
|
|
565
|
+
},
|
|
566
|
+
required: ['name', 'cronExpressions', 'timezone'],
|
|
567
|
+
},
|
|
568
|
+
zod: z.object({
|
|
569
|
+
name: z.string().min(1),
|
|
570
|
+
cronExpressions: z.array(z.string().min(1)).min(1),
|
|
571
|
+
timezone: z.string().min(1),
|
|
572
|
+
platform: z.enum(['web', 'android', 'ios']).optional(),
|
|
573
|
+
enabled: z.boolean().optional(),
|
|
574
|
+
configurationId: z.string().optional(),
|
|
575
|
+
caseFilter: z
|
|
576
|
+
.object({
|
|
577
|
+
mode: z.enum(['all', 'feature']),
|
|
578
|
+
featureIds: z.array(z.string()).default([]),
|
|
579
|
+
})
|
|
580
|
+
.optional(),
|
|
581
|
+
notifyUserIds: z.array(z.string().uuid()).optional(),
|
|
582
|
+
misfireGraceMinutes: z.number().int().positive().optional(),
|
|
583
|
+
}),
|
|
584
|
+
handler: async (args, { api, projectId, defaultPlatform }) => {
|
|
585
|
+
// Caught here rather than server-side: the API accepts feature mode with
|
|
586
|
+
// an empty id list, and the schedule then fires forever into 'no_cases'.
|
|
587
|
+
if (args.caseFilter?.mode === 'feature' &&
|
|
588
|
+
!args.caseFilter.featureIds.length) {
|
|
589
|
+
throw new Error("caseFilter.mode 'feature' needs at least one featureId — otherwise every fire resolves to zero cases. Call sixseven.list_features, or use { mode: 'all' }.");
|
|
590
|
+
}
|
|
591
|
+
const schedule = await api.createSchedule(projectId, {
|
|
592
|
+
...args,
|
|
593
|
+
platform: args.platform ?? defaultPlatform,
|
|
594
|
+
});
|
|
595
|
+
// A schedule with no configuration — its own or the project's default —
|
|
596
|
+
// is accepted by the API and then produces runs that cannot navigate
|
|
597
|
+
// anywhere. Say so at creation instead of at the first 3 a.m. failure.
|
|
598
|
+
let warning = null;
|
|
599
|
+
if (!schedule.configurationId) {
|
|
600
|
+
const project = await api.getProject(projectId).catch(() => null);
|
|
601
|
+
if (project && !project.defaultConfigurationId) {
|
|
602
|
+
warning =
|
|
603
|
+
'This schedule has no configurationId and the project has no default configuration, so its runs will start without a base URL and fail at the first navigation. Set configurationId via sixseven.update_schedule.';
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
return { ...schedule, warning };
|
|
607
|
+
},
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
name: 'sixseven.update_schedule',
|
|
611
|
+
description: 'Patch an existing schedule — pause it (enabled:false), change cadence, retarget its configuration, or edit notify recipients. Only the fields you pass are touched; changing cronExpressions or timezone recomputes nextFireAt.',
|
|
612
|
+
inputSchema: {
|
|
613
|
+
type: 'object',
|
|
614
|
+
properties: {
|
|
615
|
+
scheduleId: { type: 'string' },
|
|
616
|
+
patch: {
|
|
617
|
+
type: 'object',
|
|
618
|
+
description: 'Any subset of: name, cronExpressions, timezone, platform, enabled, configurationId (null clears), caseFilter, notifyUserIds, misfireGraceMinutes.',
|
|
619
|
+
},
|
|
620
|
+
},
|
|
621
|
+
required: ['scheduleId', 'patch'],
|
|
622
|
+
},
|
|
623
|
+
zod: z.object({
|
|
624
|
+
scheduleId: z.string().min(1),
|
|
625
|
+
patch: z.record(z.any()),
|
|
626
|
+
}),
|
|
627
|
+
handler: async ({ scheduleId, patch }, { api }) => api.updateSchedule(scheduleId, patch),
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
name: 'sixseven.delete_schedule',
|
|
631
|
+
description: 'Delete a schedule permanently. Runs it already created are kept; only the cadence goes away. Prefer sixseven.update_schedule with enabled:false when you just want to pause it.',
|
|
632
|
+
inputSchema: {
|
|
633
|
+
type: 'object',
|
|
634
|
+
properties: { scheduleId: { type: 'string' } },
|
|
635
|
+
required: ['scheduleId'],
|
|
636
|
+
},
|
|
637
|
+
zod: z.object({ scheduleId: z.string().min(1) }),
|
|
638
|
+
handler: async ({ scheduleId }, { api }) => {
|
|
639
|
+
await api.deleteSchedule(scheduleId);
|
|
640
|
+
return { ok: true, deletedScheduleId: scheduleId };
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
name: 'sixseven.run_schedule_now',
|
|
645
|
+
description: "Fire a schedule immediately on the identical code path the clock uses — the real end-to-end test of a cadence, and it works on a paused (enabled:false) schedule too. Returns { outcome, runId }: 'run_created' means a run was started (feed runId to sixseven.wait_for_run), while 'skipped_overlap' means a previous run of this schedule is still live and 'no_cases' means the case filter matched nothing. Skips are reported, not thrown.",
|
|
646
|
+
inputSchema: {
|
|
647
|
+
type: 'object',
|
|
648
|
+
properties: { scheduleId: { type: 'string' } },
|
|
649
|
+
required: ['scheduleId'],
|
|
650
|
+
},
|
|
651
|
+
zod: z.object({ scheduleId: z.string().min(1) }),
|
|
652
|
+
handler: async ({ scheduleId }, { api, baseUrl }) => {
|
|
653
|
+
const { outcome, skipped } = await api.runScheduleNow(scheduleId);
|
|
654
|
+
// The route answers with the outcome alone, so the runId — the one thing
|
|
655
|
+
// a caller needs next — is read back from the fire it just recorded.
|
|
656
|
+
let runId = null;
|
|
657
|
+
if (outcome === 'run_created') {
|
|
658
|
+
const fires = await api
|
|
659
|
+
.listScheduleFires(scheduleId)
|
|
660
|
+
.catch(() => ({ items: [], hasMore: false }));
|
|
661
|
+
runId = fires.items[0]?.runId ?? null;
|
|
662
|
+
}
|
|
663
|
+
return {
|
|
664
|
+
scheduleId,
|
|
665
|
+
outcome,
|
|
666
|
+
skipped,
|
|
667
|
+
runId,
|
|
668
|
+
viewUrl: runId ? `${baseUrl}/runs/${runId}` : null,
|
|
669
|
+
};
|
|
670
|
+
},
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
name: 'sixseven.list_schedule_fires',
|
|
674
|
+
description: "History of a schedule's occurrences, newest first: when it fired, the outcome, and the run it created (if any). This is the place to find out why a schedule appeared to do nothing — skipped_overlap, skipped_misfire, skipped_capacity, and no_cases all show up here.",
|
|
675
|
+
inputSchema: {
|
|
676
|
+
type: 'object',
|
|
677
|
+
properties: {
|
|
678
|
+
scheduleId: { type: 'string' },
|
|
679
|
+
page: { type: 'number', default: 1 },
|
|
680
|
+
},
|
|
681
|
+
required: ['scheduleId'],
|
|
682
|
+
},
|
|
683
|
+
zod: z.object({
|
|
684
|
+
scheduleId: z.string().min(1),
|
|
685
|
+
page: z.number().int().positive().optional(),
|
|
686
|
+
}),
|
|
687
|
+
handler: async ({ scheduleId, page }, { api }) => api.listScheduleFires(scheduleId, page),
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
name: 'sixseven.list_schedule_recipients',
|
|
691
|
+
description: "The users that may be put in a schedule's notifyUserIds. Resolved exactly the way the server resolves recipients at send time, so a user missing from this list would silently receive nothing if added anyway — including, possibly, your own account.",
|
|
692
|
+
inputSchema: { type: 'object', properties: {} },
|
|
693
|
+
zod: z.object({}).passthrough(),
|
|
694
|
+
handler: async (_args, { api, projectId }) => api.listScheduleRecipients(projectId),
|
|
695
|
+
},
|
|
696
|
+
// ---------- SixSeven: auto-explore ----------
|
|
697
|
+
{
|
|
698
|
+
name: 'sixseven.start_exploration',
|
|
699
|
+
description: "Trigger SixSeven's BFS crawler (Puppeteer-based, runs server-side) on a set of seed URLs for the bound project. Login via EXPLORER_USERNAME/PASSWORD is automatic when configured. Returns a snapshot immediately (job runs in background); poll with sixseven.get_exploration. One job per project at a time — calling this while a job is already running returns the live snapshot.",
|
|
700
|
+
inputSchema: {
|
|
701
|
+
type: 'object',
|
|
702
|
+
properties: {
|
|
703
|
+
seedUrls: { type: 'array', items: { type: 'string' }, minItems: 1 },
|
|
704
|
+
configurationId: { type: 'string' },
|
|
705
|
+
maxDepth: { type: 'number' },
|
|
706
|
+
maxPages: { type: 'number' },
|
|
707
|
+
},
|
|
708
|
+
required: ['seedUrls'],
|
|
709
|
+
},
|
|
710
|
+
zod: z.object({
|
|
711
|
+
seedUrls: z.array(z.string().url()).min(1),
|
|
712
|
+
configurationId: z.string().optional(),
|
|
713
|
+
maxDepth: z.number().int().positive().max(20).optional(),
|
|
714
|
+
maxPages: z.number().int().positive().max(500).optional(),
|
|
715
|
+
}),
|
|
716
|
+
handler: async (args, { api, projectId }) => api.startExploration(projectId, args),
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
name: 'sixseven.get_exploration',
|
|
720
|
+
description: 'Return the latest exploration snapshot for the bound project (or null if none has ever run). Shape: { jobId, status, visited, anchorsUpserted, loggedIn, errors[] }. Use to await completion before generating testcases that depend on discovered routes/anchors.',
|
|
721
|
+
inputSchema: { type: 'object', properties: {} },
|
|
722
|
+
zod: z.object({}).passthrough(),
|
|
723
|
+
handler: async (_args, { api, projectId }) => api.getExploration(projectId),
|
|
724
|
+
},
|
|
725
|
+
// ---------- SixSeven: bug filing ----------
|
|
726
|
+
{
|
|
727
|
+
name: 'sixseven.file_bug',
|
|
728
|
+
description: "Open an issue report (bug) against the bound SixSeven project. Use this only after the auto-fix loop has identified a real application defect (not a flaky testcase). Severity must be 'critical', 'high', 'medium', or 'low'. Pass evidence URLs (screenshotUrl from sixseven.get_evidence) in evidences[].",
|
|
729
|
+
inputSchema: {
|
|
730
|
+
type: 'object',
|
|
731
|
+
properties: {
|
|
732
|
+
title: { type: 'string' },
|
|
733
|
+
severity: {
|
|
734
|
+
type: 'string',
|
|
735
|
+
enum: ['critical', 'high', 'medium', 'low'],
|
|
736
|
+
},
|
|
737
|
+
description: { type: 'string' },
|
|
738
|
+
pageUrl: { type: 'string' },
|
|
739
|
+
evidences: { type: 'array', items: { type: 'string' } },
|
|
740
|
+
},
|
|
741
|
+
required: ['title', 'severity'],
|
|
742
|
+
},
|
|
743
|
+
zod: z.object({
|
|
744
|
+
title: z.string().min(1).max(200),
|
|
745
|
+
severity: z.enum(['critical', 'high', 'medium', 'low']),
|
|
746
|
+
description: z.string().optional(),
|
|
747
|
+
pageUrl: z.string().optional(),
|
|
748
|
+
evidences: z.array(z.string()).optional(),
|
|
749
|
+
}),
|
|
750
|
+
handler: async (args, { api, projectId }) => api.createIssueReport({ ...args, projectId }),
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
name: 'sixseven.list_bugs',
|
|
754
|
+
description: 'List issue reports (bugs) for the bound SixSeven project. Use to check whether a defect has already been reported before filing a new one.',
|
|
755
|
+
inputSchema: { type: 'object', properties: {} },
|
|
756
|
+
zod: z.object({}).passthrough(),
|
|
757
|
+
handler: async (_args, { api, projectId }) => api.listIssueReports(projectId),
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
name: 'sixseven.get_bug',
|
|
761
|
+
description: 'Fetch a single issue report by id.',
|
|
762
|
+
inputSchema: {
|
|
763
|
+
type: 'object',
|
|
764
|
+
properties: { id: { type: 'string' } },
|
|
765
|
+
required: ['id'],
|
|
766
|
+
},
|
|
767
|
+
zod: z.object({ id: z.string().min(1) }),
|
|
768
|
+
handler: async ({ id }, { api }) => api.getIssueReport(id),
|
|
769
|
+
},
|
|
770
|
+
// ---------- SixSeven: project context ----------
|
|
771
|
+
{
|
|
772
|
+
name: 'sixseven.whoami',
|
|
773
|
+
description: 'Return the signed-in AuraCheck user, the base URL, how the token was supplied, and the project this MCP session is bound to (null = pass projectId to project tools; see sixseven.list_projects).',
|
|
774
|
+
inputSchema: { type: 'object', properties: {} },
|
|
775
|
+
zod: z.object({}).passthrough(),
|
|
776
|
+
handler: async (_args, { api, boundProjectId, baseUrl, tokenSource }) => {
|
|
777
|
+
const [user, project] = await Promise.all([
|
|
778
|
+
api.me(),
|
|
779
|
+
boundProjectId
|
|
780
|
+
? api.getProject(boundProjectId).catch(() => null)
|
|
781
|
+
: Promise.resolve(null),
|
|
782
|
+
]);
|
|
783
|
+
return {
|
|
784
|
+
user,
|
|
785
|
+
baseUrl,
|
|
786
|
+
tokenSource,
|
|
787
|
+
cliVersion: CLI_VERSION,
|
|
788
|
+
projectId: boundProjectId,
|
|
789
|
+
project,
|
|
790
|
+
};
|
|
791
|
+
},
|
|
792
|
+
},
|
|
793
|
+
];
|
|
794
|
+
const CODE_TOOLS = new Set([
|
|
795
|
+
'sixseven.read_code',
|
|
796
|
+
'sixseven.list_dir',
|
|
797
|
+
'sixseven.search_code',
|
|
798
|
+
]);
|
|
799
|
+
/** Tools whose handler works on a project: they take an optional `projectId`. */
|
|
800
|
+
const PROJECT_TOOLS = new Set([
|
|
801
|
+
'sixseven.list_features',
|
|
802
|
+
'sixseven.create_feature',
|
|
803
|
+
'sixseven.list_testcases',
|
|
804
|
+
'sixseven.get_testcase',
|
|
805
|
+
'sixseven.list_runs',
|
|
806
|
+
'sixseven.create_run',
|
|
807
|
+
'sixseven.list_schedules',
|
|
808
|
+
'sixseven.create_schedule',
|
|
809
|
+
'sixseven.list_schedule_recipients',
|
|
810
|
+
'sixseven.start_exploration',
|
|
811
|
+
'sixseven.get_exploration',
|
|
812
|
+
'sixseven.file_bug',
|
|
813
|
+
'sixseven.list_bugs',
|
|
814
|
+
]);
|
|
815
|
+
const PROJECT_ID_PROPERTY = {
|
|
816
|
+
type: 'string',
|
|
817
|
+
description: 'AuraCheck project id (see sixseven.list_projects). Defaults to the project bound in .sixseven/config.json.',
|
|
818
|
+
};
|
|
819
|
+
/** The input schema advertised to the client (adds `projectId` where it applies). */
|
|
820
|
+
function advertisedSchema(t) {
|
|
821
|
+
if (!PROJECT_TOOLS.has(t.name))
|
|
822
|
+
return t.inputSchema;
|
|
823
|
+
const props = (t.inputSchema.properties ?? {});
|
|
824
|
+
return {
|
|
825
|
+
...t.inputSchema,
|
|
826
|
+
properties: { ...props, projectId: PROJECT_ID_PROPERTY },
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
function logErr(msg) {
|
|
830
|
+
process.stderr.write(`[sixseven-mcp] ${msg}\n`);
|
|
831
|
+
}
|
|
832
|
+
class NotSignedInError extends Error {
|
|
833
|
+
constructor(baseUrl) {
|
|
834
|
+
super(`Not signed in to AuraCheck (${baseUrl}). Run \`auracheck login\` in a terminal — the MCP server picks the new sign-in up on the next call, no restart needed.`);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Start the MCP server on stdio. It never exits for a missing project config
|
|
839
|
+
* or sign-in: Claude Code would only show "Failed to connect". Instead every
|
|
840
|
+
* tool call explains what is missing, and the saved token is re-read per call
|
|
841
|
+
* so `auracheck login` takes effect without restarting the server.
|
|
842
|
+
*/
|
|
843
|
+
export async function runMcpServer(overrides = {}) {
|
|
844
|
+
const ctx = await resolveContext(process.cwd(), overrides);
|
|
845
|
+
const reader = new SourceReader({
|
|
846
|
+
repoRoot: ctx.repoRoot,
|
|
847
|
+
config: ctx.config ?? {
|
|
848
|
+
baseUrl: ctx.baseUrl,
|
|
849
|
+
projectId: ctx.projectId ?? '',
|
|
850
|
+
defaultFeatureId: null,
|
|
851
|
+
codeRoots: ['.'],
|
|
852
|
+
exclude: DEFAULT_EXCLUDE,
|
|
853
|
+
platform: ctx.platform,
|
|
854
|
+
},
|
|
855
|
+
});
|
|
856
|
+
const defaultFeatureId = ctx.config?.defaultFeatureId ?? null;
|
|
857
|
+
let cached = null;
|
|
858
|
+
async function currentApi() {
|
|
859
|
+
const token = ctx.tokenSource === 'env' ? ctx.token : await getToken(ctx.baseUrl);
|
|
860
|
+
if (!token)
|
|
861
|
+
throw new NotSignedInError(ctx.baseUrl);
|
|
862
|
+
if (cached?.token !== token) {
|
|
863
|
+
cached = { token, api: new SixSevenApi({ baseUrl: ctx.baseUrl, token }) };
|
|
864
|
+
}
|
|
865
|
+
return cached.api;
|
|
866
|
+
}
|
|
867
|
+
const server = new Server({ name: 'sixseven', version: CLI_VERSION }, { capabilities: { tools: {} } });
|
|
868
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
869
|
+
tools: tools.map((t) => ({
|
|
870
|
+
name: t.name,
|
|
871
|
+
description: t.description,
|
|
872
|
+
inputSchema: advertisedSchema(t),
|
|
873
|
+
})),
|
|
874
|
+
}));
|
|
875
|
+
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
876
|
+
const tool = tools.find((t) => t.name === req.params.name);
|
|
877
|
+
if (!tool) {
|
|
878
|
+
return {
|
|
879
|
+
isError: true,
|
|
880
|
+
content: [{ type: 'text', text: `Unknown tool: ${req.params.name}` }],
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
try {
|
|
884
|
+
let args = (req.params.arguments ?? {});
|
|
885
|
+
let callProjectId = ctx.projectId;
|
|
886
|
+
if (PROJECT_TOOLS.has(tool.name)) {
|
|
887
|
+
// `projectId` is ours, not part of the tool's own schema.
|
|
888
|
+
const { projectId: argProjectId, ...rest } = args;
|
|
889
|
+
if (typeof argProjectId === 'string' && argProjectId.trim()) {
|
|
890
|
+
callProjectId = argProjectId.trim();
|
|
891
|
+
}
|
|
892
|
+
args = rest;
|
|
893
|
+
}
|
|
894
|
+
const parsed = tool.zod.parse(args);
|
|
895
|
+
// The code tools read the local repo only; they need no sign-in.
|
|
896
|
+
const api = CODE_TOOLS.has(tool.name)
|
|
897
|
+
? null
|
|
898
|
+
: await currentApi();
|
|
899
|
+
const toolCtx = {
|
|
900
|
+
api,
|
|
901
|
+
reader,
|
|
902
|
+
get projectId() {
|
|
903
|
+
if (!callProjectId) {
|
|
904
|
+
throw new Error('No AuraCheck project for this call: pass `projectId` (find it with sixseven.list_projects), or bind this repo with `auracheck init`.');
|
|
905
|
+
}
|
|
906
|
+
return callProjectId;
|
|
907
|
+
},
|
|
908
|
+
boundProjectId: ctx.projectId,
|
|
909
|
+
defaultFeatureId,
|
|
910
|
+
defaultPlatform: ctx.platform,
|
|
911
|
+
baseUrl: ctx.baseUrl,
|
|
912
|
+
// Re-read per call: a login after start comes from the credentials file.
|
|
913
|
+
tokenSource: ctx.tokenSource === 'env' ? 'env' : 'credentials',
|
|
914
|
+
};
|
|
915
|
+
const result = await tool.handler(parsed, toolCtx);
|
|
916
|
+
return {
|
|
917
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
catch (err) {
|
|
921
|
+
return {
|
|
922
|
+
isError: true,
|
|
923
|
+
content: [
|
|
924
|
+
{
|
|
925
|
+
type: 'text',
|
|
926
|
+
text: err?.message ?? String(err),
|
|
927
|
+
},
|
|
928
|
+
],
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
const transport = new StdioServerTransport();
|
|
933
|
+
await server.connect(transport);
|
|
934
|
+
logErr(`ready v${CLI_VERSION}. baseUrl=${ctx.baseUrl} project=${ctx.projectId ?? '(none bound)'} repo=${ctx.repoRoot}`);
|
|
935
|
+
// Diagnose the sign-in once, to stderr only (Claude Code's MCP log). Never
|
|
936
|
+
// fatal: tool calls carry the same explanation.
|
|
937
|
+
currentApi()
|
|
938
|
+
.then((api) => api.me())
|
|
939
|
+
.then((u) => logErr(`signed in as ${u.email} (${u.role})`))
|
|
940
|
+
.catch((err) => logErr(`sign-in check failed: ${err instanceof ApiError || err instanceof NotSignedInError ? err.message : String(err)}`));
|
|
941
|
+
}
|
|
942
|
+
//# sourceMappingURL=server.js.map
|