@constructive-io/graphql-codegen 4.24.5 → 4.26.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/core/codegen/cli/docs-generator.d.ts +2 -4
- package/core/codegen/cli/docs-generator.js +74 -472
- package/core/codegen/cli/index.d.ts +2 -2
- package/core/codegen/cli/index.js +1 -3
- package/core/codegen/cli/table-command-generator.js +165 -16
- package/core/codegen/docs-utils.d.ts +0 -6
- package/core/codegen/docs-utils.js +13 -7
- package/core/codegen/hooks-docs-generator.d.ts +1 -2
- package/core/codegen/hooks-docs-generator.js +0 -113
- package/core/codegen/orm/docs-generator.d.ts +1 -2
- package/core/codegen/orm/docs-generator.js +0 -126
- package/core/codegen/target-docs-generator.d.ts +1 -2
- package/core/codegen/target-docs-generator.js +0 -13
- package/core/codegen/templates/cli-utils.ts +117 -0
- package/core/codegen/utils.d.ts +2 -2
- package/core/codegen/utils.js +2 -2
- package/core/generate.js +0 -26
- package/esm/core/codegen/cli/docs-generator.d.ts +2 -4
- package/esm/core/codegen/cli/docs-generator.js +75 -471
- package/esm/core/codegen/cli/index.d.ts +2 -2
- package/esm/core/codegen/cli/index.js +1 -1
- package/esm/core/codegen/cli/table-command-generator.js +166 -17
- package/esm/core/codegen/docs-utils.d.ts +0 -6
- package/esm/core/codegen/docs-utils.js +13 -7
- package/esm/core/codegen/hooks-docs-generator.d.ts +1 -2
- package/esm/core/codegen/hooks-docs-generator.js +2 -114
- package/esm/core/codegen/orm/docs-generator.d.ts +1 -2
- package/esm/core/codegen/orm/docs-generator.js +1 -126
- package/esm/core/codegen/target-docs-generator.d.ts +1 -2
- package/esm/core/codegen/target-docs-generator.js +0 -12
- package/esm/core/codegen/utils.d.ts +2 -2
- package/esm/core/codegen/utils.js +2 -2
- package/esm/core/generate.js +4 -30
- package/esm/types/config.d.ts +1 -8
- package/package.json +16 -16
- package/types/config.d.ts +1 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toKebabCase } from 'komoji';
|
|
2
|
-
import { flattenArgs, flattenedArgsToFlags, cleanTypeName, getEditableFields, categorizeSpecialFields, buildSpecialFieldsMarkdown, getReadmeHeader, getReadmeFooter,
|
|
2
|
+
import { flattenArgs, flattenedArgsToFlags, cleanTypeName, getEditableFields, categorizeSpecialFields, buildSpecialFieldsMarkdown, getReadmeHeader, getReadmeFooter, buildSkillFile, buildSkillReference, } from '../docs-utils';
|
|
3
3
|
import { getScalarFields, getTableNames, getPrimaryKeyInfo, } from '../utils';
|
|
4
4
|
import { getFieldsWithDefaults } from './table-command-generator';
|
|
5
5
|
export { resolveDocsConfig } from '../docs-utils';
|
|
@@ -91,6 +91,12 @@ export function generateReadme(tables, customOperations, toolName, registry) {
|
|
|
91
91
|
lines.push('| Subcommand | Description |');
|
|
92
92
|
lines.push('|------------|-------------|');
|
|
93
93
|
lines.push(`| \`list\` | List all ${singularName} records |`);
|
|
94
|
+
lines.push(`| \`find-first\` | Find first matching ${singularName} record |`);
|
|
95
|
+
const readmeSpecialGroups = categorizeSpecialFields(table, registry);
|
|
96
|
+
const readmeHasSearch = readmeSpecialGroups.some((g) => g.category === 'search' || g.category === 'embedding');
|
|
97
|
+
if (readmeHasSearch) {
|
|
98
|
+
lines.push(`| \`search <query>\` | Search ${singularName} records |`);
|
|
99
|
+
}
|
|
94
100
|
lines.push(`| \`get\` | Get a ${singularName} by ${pk.name} |`);
|
|
95
101
|
lines.push(`| \`create\` | Create a new ${singularName} |`);
|
|
96
102
|
lines.push(`| \`update\` | Update an existing ${singularName} |`);
|
|
@@ -213,232 +219,6 @@ export function generateAgentsDocs(tables, customOperations, toolName, _registry
|
|
|
213
219
|
content: lines.join('\n'),
|
|
214
220
|
};
|
|
215
221
|
}
|
|
216
|
-
export function getCliMcpTools(tables, customOperations, toolName, registry) {
|
|
217
|
-
const tools = [];
|
|
218
|
-
tools.push({
|
|
219
|
-
name: `${toolName}_context_create`,
|
|
220
|
-
description: 'Create a named API context pointing at a GraphQL endpoint',
|
|
221
|
-
inputSchema: {
|
|
222
|
-
type: 'object',
|
|
223
|
-
properties: {
|
|
224
|
-
name: { type: 'string', description: 'Context name' },
|
|
225
|
-
endpoint: { type: 'string', description: 'GraphQL endpoint URL' },
|
|
226
|
-
},
|
|
227
|
-
required: ['name', 'endpoint'],
|
|
228
|
-
},
|
|
229
|
-
});
|
|
230
|
-
tools.push({
|
|
231
|
-
name: `${toolName}_context_list`,
|
|
232
|
-
description: 'List all configured API contexts',
|
|
233
|
-
inputSchema: { type: 'object', properties: {} },
|
|
234
|
-
});
|
|
235
|
-
tools.push({
|
|
236
|
-
name: `${toolName}_context_use`,
|
|
237
|
-
description: 'Set the active API context',
|
|
238
|
-
inputSchema: {
|
|
239
|
-
type: 'object',
|
|
240
|
-
properties: {
|
|
241
|
-
name: { type: 'string', description: 'Context name to activate' },
|
|
242
|
-
},
|
|
243
|
-
required: ['name'],
|
|
244
|
-
},
|
|
245
|
-
});
|
|
246
|
-
tools.push({
|
|
247
|
-
name: `${toolName}_context_current`,
|
|
248
|
-
description: 'Show the currently active API context',
|
|
249
|
-
inputSchema: { type: 'object', properties: {} },
|
|
250
|
-
});
|
|
251
|
-
tools.push({
|
|
252
|
-
name: `${toolName}_context_delete`,
|
|
253
|
-
description: 'Delete an API context',
|
|
254
|
-
inputSchema: {
|
|
255
|
-
type: 'object',
|
|
256
|
-
properties: {
|
|
257
|
-
name: { type: 'string', description: 'Context name to delete' },
|
|
258
|
-
},
|
|
259
|
-
required: ['name'],
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
tools.push({
|
|
263
|
-
name: `${toolName}_auth_set_token`,
|
|
264
|
-
description: 'Store a bearer token for the current context',
|
|
265
|
-
inputSchema: {
|
|
266
|
-
type: 'object',
|
|
267
|
-
properties: {
|
|
268
|
-
token: { type: 'string', description: 'Bearer token value' },
|
|
269
|
-
},
|
|
270
|
-
required: ['token'],
|
|
271
|
-
},
|
|
272
|
-
});
|
|
273
|
-
tools.push({
|
|
274
|
-
name: `${toolName}_auth_status`,
|
|
275
|
-
description: 'Show authentication status for all contexts',
|
|
276
|
-
inputSchema: { type: 'object', properties: {} },
|
|
277
|
-
});
|
|
278
|
-
tools.push({
|
|
279
|
-
name: `${toolName}_auth_logout`,
|
|
280
|
-
description: 'Remove credentials for the current context',
|
|
281
|
-
inputSchema: { type: 'object', properties: {} },
|
|
282
|
-
});
|
|
283
|
-
tools.push({
|
|
284
|
-
name: `${toolName}_config_get`,
|
|
285
|
-
description: 'Get a config variable value for the current context',
|
|
286
|
-
inputSchema: {
|
|
287
|
-
type: 'object',
|
|
288
|
-
properties: {
|
|
289
|
-
key: { type: 'string', description: 'Variable name' },
|
|
290
|
-
},
|
|
291
|
-
required: ['key'],
|
|
292
|
-
},
|
|
293
|
-
});
|
|
294
|
-
tools.push({
|
|
295
|
-
name: `${toolName}_config_set`,
|
|
296
|
-
description: 'Set a config variable value for the current context',
|
|
297
|
-
inputSchema: {
|
|
298
|
-
type: 'object',
|
|
299
|
-
properties: {
|
|
300
|
-
key: { type: 'string', description: 'Variable name' },
|
|
301
|
-
value: { type: 'string', description: 'Variable value' },
|
|
302
|
-
},
|
|
303
|
-
required: ['key', 'value'],
|
|
304
|
-
},
|
|
305
|
-
});
|
|
306
|
-
tools.push({
|
|
307
|
-
name: `${toolName}_config_list`,
|
|
308
|
-
description: 'List all config variables for the current context',
|
|
309
|
-
inputSchema: { type: 'object', properties: {} },
|
|
310
|
-
});
|
|
311
|
-
tools.push({
|
|
312
|
-
name: `${toolName}_config_delete`,
|
|
313
|
-
description: 'Delete a config variable for the current context',
|
|
314
|
-
inputSchema: {
|
|
315
|
-
type: 'object',
|
|
316
|
-
properties: {
|
|
317
|
-
key: { type: 'string', description: 'Variable name to delete' },
|
|
318
|
-
},
|
|
319
|
-
required: ['key'],
|
|
320
|
-
},
|
|
321
|
-
});
|
|
322
|
-
for (const table of tables) {
|
|
323
|
-
const { singularName } = getTableNames(table);
|
|
324
|
-
const kebab = toKebabCase(singularName);
|
|
325
|
-
const pk = getPrimaryKeyInfo(table)[0];
|
|
326
|
-
const scalarFields = getScalarFields(table);
|
|
327
|
-
const editableFields = getEditableFields(table, registry);
|
|
328
|
-
const defaultFields = getFieldsWithDefaults(table, registry);
|
|
329
|
-
const requiredCreateFieldNames = editableFields
|
|
330
|
-
.filter((f) => !defaultFields.has(f.name))
|
|
331
|
-
.map((f) => f.name);
|
|
332
|
-
tools.push({
|
|
333
|
-
name: `${toolName}_${kebab}_list`,
|
|
334
|
-
description: `List all ${table.name} records`,
|
|
335
|
-
inputSchema: { type: 'object', properties: {} },
|
|
336
|
-
});
|
|
337
|
-
tools.push({
|
|
338
|
-
name: `${toolName}_${kebab}_get`,
|
|
339
|
-
description: `Get a single ${table.name} record by ${pk.name}`,
|
|
340
|
-
inputSchema: {
|
|
341
|
-
type: 'object',
|
|
342
|
-
properties: {
|
|
343
|
-
[pk.name]: {
|
|
344
|
-
type: gqlTypeToJsonSchemaType(pk.gqlType),
|
|
345
|
-
description: `${table.name} ${pk.name}`,
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
required: [pk.name],
|
|
349
|
-
},
|
|
350
|
-
});
|
|
351
|
-
const createProps = {};
|
|
352
|
-
for (const f of editableFields) {
|
|
353
|
-
createProps[f.name] = {
|
|
354
|
-
type: gqlTypeToJsonSchemaType(cleanTypeName(f.type.gqlType)),
|
|
355
|
-
description: `${table.name} ${f.name}`,
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
tools.push({
|
|
359
|
-
name: `${toolName}_${kebab}_create`,
|
|
360
|
-
description: `Create a new ${table.name} record`,
|
|
361
|
-
inputSchema: {
|
|
362
|
-
type: 'object',
|
|
363
|
-
properties: createProps,
|
|
364
|
-
...(requiredCreateFieldNames.length > 0 ? { required: requiredCreateFieldNames } : {}),
|
|
365
|
-
},
|
|
366
|
-
});
|
|
367
|
-
const updateProps = {
|
|
368
|
-
[pk.name]: {
|
|
369
|
-
type: gqlTypeToJsonSchemaType(pk.gqlType),
|
|
370
|
-
description: `${table.name} ${pk.name}`,
|
|
371
|
-
},
|
|
372
|
-
};
|
|
373
|
-
for (const f of editableFields) {
|
|
374
|
-
updateProps[f.name] = {
|
|
375
|
-
type: gqlTypeToJsonSchemaType(cleanTypeName(f.type.gqlType)),
|
|
376
|
-
description: `${table.name} ${f.name}`,
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
tools.push({
|
|
380
|
-
name: `${toolName}_${kebab}_update`,
|
|
381
|
-
description: `Update an existing ${table.name} record`,
|
|
382
|
-
inputSchema: {
|
|
383
|
-
type: 'object',
|
|
384
|
-
properties: updateProps,
|
|
385
|
-
required: [pk.name],
|
|
386
|
-
},
|
|
387
|
-
});
|
|
388
|
-
tools.push({
|
|
389
|
-
name: `${toolName}_${kebab}_delete`,
|
|
390
|
-
description: `Delete a ${table.name} record by ${pk.name}`,
|
|
391
|
-
inputSchema: {
|
|
392
|
-
type: 'object',
|
|
393
|
-
properties: {
|
|
394
|
-
[pk.name]: {
|
|
395
|
-
type: gqlTypeToJsonSchemaType(pk.gqlType),
|
|
396
|
-
description: `${table.name} ${pk.name}`,
|
|
397
|
-
},
|
|
398
|
-
},
|
|
399
|
-
required: [pk.name],
|
|
400
|
-
},
|
|
401
|
-
});
|
|
402
|
-
tools.push({
|
|
403
|
-
name: `${toolName}_${kebab}_fields`,
|
|
404
|
-
description: `List available fields for ${table.name}`,
|
|
405
|
-
inputSchema: { type: 'object', properties: {} },
|
|
406
|
-
_meta: {
|
|
407
|
-
fields: scalarFields.map((f) => ({
|
|
408
|
-
name: f.name,
|
|
409
|
-
type: cleanTypeName(f.type.gqlType),
|
|
410
|
-
editable: editableFields.some((ef) => ef.name === f.name),
|
|
411
|
-
primaryKey: f.name === pk.name,
|
|
412
|
-
})),
|
|
413
|
-
},
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
for (const op of customOperations) {
|
|
417
|
-
const kebab = toKebabCase(op.name);
|
|
418
|
-
const flat = flattenArgs(op.args, registry);
|
|
419
|
-
const props = {};
|
|
420
|
-
const required = [];
|
|
421
|
-
for (const a of flat) {
|
|
422
|
-
props[a.flag] = {
|
|
423
|
-
type: gqlTypeToJsonSchemaType(a.type),
|
|
424
|
-
description: a.description || a.flag,
|
|
425
|
-
};
|
|
426
|
-
if (a.required) {
|
|
427
|
-
required.push(a.flag);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
tools.push({
|
|
431
|
-
name: `${toolName}_${kebab}`,
|
|
432
|
-
description: op.description || op.name,
|
|
433
|
-
inputSchema: {
|
|
434
|
-
type: 'object',
|
|
435
|
-
properties: props,
|
|
436
|
-
...(required.length > 0 ? { required } : {}),
|
|
437
|
-
},
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
return tools;
|
|
441
|
-
}
|
|
442
222
|
export function generateSkills(tables, customOperations, toolName, targetName, registry) {
|
|
443
223
|
const files = [];
|
|
444
224
|
const skillName = `cli-${targetName}`;
|
|
@@ -548,6 +328,12 @@ export function generateSkills(tables, customOperations, toolName, targetName, r
|
|
|
548
328
|
description: skillSpecialDesc,
|
|
549
329
|
usage: [
|
|
550
330
|
`${toolName} ${kebab} list`,
|
|
331
|
+
`${toolName} ${kebab} list --where.<field>.<op> <value> --orderBy <values>`,
|
|
332
|
+
`${toolName} ${kebab} list --limit 10 --after <cursor>`,
|
|
333
|
+
`${toolName} ${kebab} find-first --where.<field>.<op> <value>`,
|
|
334
|
+
...(skillSpecialGroups.some((g) => g.category === 'search' || g.category === 'embedding')
|
|
335
|
+
? [`${toolName} ${kebab} search <query>`]
|
|
336
|
+
: []),
|
|
551
337
|
`${toolName} ${kebab} get --${pk.name} <${cleanTypeName(pk.gqlType)}>`,
|
|
552
338
|
`${toolName} ${kebab} create ${createFlags}`,
|
|
553
339
|
`${toolName} ${kebab} update --${pk.name} <${cleanTypeName(pk.gqlType)}> ${editableFields.map((f) => `[--${f.name} <${cleanTypeName(f.type.gqlType)}>]`).join(' ')}`,
|
|
@@ -555,9 +341,35 @@ export function generateSkills(tables, customOperations, toolName, targetName, r
|
|
|
555
341
|
],
|
|
556
342
|
examples: [
|
|
557
343
|
{
|
|
558
|
-
description: `List
|
|
344
|
+
description: `List ${singularName} records`,
|
|
559
345
|
code: [`${toolName} ${kebab} list`],
|
|
560
346
|
},
|
|
347
|
+
{
|
|
348
|
+
description: `List ${singularName} records with pagination`,
|
|
349
|
+
code: [`${toolName} ${kebab} list --limit 10 --offset 0`],
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
description: `List ${singularName} records with cursor pagination`,
|
|
353
|
+
code: [`${toolName} ${kebab} list --limit 10 --after <cursor>`],
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
description: `Find first matching ${singularName}`,
|
|
357
|
+
code: [`${toolName} ${kebab} find-first --where.${pk.name}.equalTo <value>`],
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
description: `List ${singularName} records with field selection`,
|
|
361
|
+
code: [`${toolName} ${kebab} list --fields id,${pk.name}`],
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
description: `List ${singularName} records with filtering and ordering`,
|
|
365
|
+
code: [`${toolName} ${kebab} list --where.${pk.name}.equalTo <value> --orderBy ${pk.name.replace(/([A-Z])/g, '_$1').toUpperCase()}_ASC`],
|
|
366
|
+
},
|
|
367
|
+
...(skillSpecialGroups.some((g) => g.category === 'search' || g.category === 'embedding')
|
|
368
|
+
? [{
|
|
369
|
+
description: `Search ${singularName} records`,
|
|
370
|
+
code: [`${toolName} ${kebab} search "query text" --limit 10 --fields id,searchScore`],
|
|
371
|
+
}]
|
|
372
|
+
: []),
|
|
561
373
|
{
|
|
562
374
|
description: `Create a ${singularName}`,
|
|
563
375
|
code: [
|
|
@@ -812,6 +624,12 @@ export function generateMultiTargetReadme(input) {
|
|
|
812
624
|
lines.push('| Subcommand | Description |');
|
|
813
625
|
lines.push('|------------|-------------|');
|
|
814
626
|
lines.push(`| \`list\` | List all ${singularName} records |`);
|
|
627
|
+
lines.push(`| \`find-first\` | Find first matching ${singularName} record |`);
|
|
628
|
+
const mtReadmeSpecialGroups = categorizeSpecialFields(table, registry);
|
|
629
|
+
const mtReadmeHasSearch = mtReadmeSpecialGroups.some((g) => g.category === 'search' || g.category === 'embedding');
|
|
630
|
+
if (mtReadmeHasSearch) {
|
|
631
|
+
lines.push(`| \`search <query>\` | Search ${singularName} records |`);
|
|
632
|
+
}
|
|
815
633
|
lines.push(`| \`get\` | Get a ${singularName} by ${pk.name} |`);
|
|
816
634
|
lines.push(`| \`create\` | Create a new ${singularName} |`);
|
|
817
635
|
lines.push(`| \`update\` | Update an existing ${singularName} |`);
|
|
@@ -949,248 +767,6 @@ export function generateMultiTargetAgentsDocs(input) {
|
|
|
949
767
|
content: lines.join('\n'),
|
|
950
768
|
};
|
|
951
769
|
}
|
|
952
|
-
export function getMultiTargetCliMcpTools(input) {
|
|
953
|
-
const { toolName, builtinNames, targets, registry } = input;
|
|
954
|
-
const tools = [];
|
|
955
|
-
const contextEndpointProps = {
|
|
956
|
-
name: { type: 'string', description: 'Context name' },
|
|
957
|
-
};
|
|
958
|
-
for (const tgt of targets) {
|
|
959
|
-
contextEndpointProps[`${tgt.name}_endpoint`] = {
|
|
960
|
-
type: 'string',
|
|
961
|
-
description: `${tgt.name} GraphQL endpoint (default: ${tgt.endpoint})`,
|
|
962
|
-
};
|
|
963
|
-
}
|
|
964
|
-
tools.push({
|
|
965
|
-
name: `${toolName}_${builtinNames.context}_create`,
|
|
966
|
-
description: 'Create a named API context with per-target endpoint overrides',
|
|
967
|
-
inputSchema: {
|
|
968
|
-
type: 'object',
|
|
969
|
-
properties: contextEndpointProps,
|
|
970
|
-
required: ['name'],
|
|
971
|
-
},
|
|
972
|
-
});
|
|
973
|
-
tools.push({
|
|
974
|
-
name: `${toolName}_${builtinNames.context}_list`,
|
|
975
|
-
description: 'List all configured API contexts',
|
|
976
|
-
inputSchema: { type: 'object', properties: {} },
|
|
977
|
-
});
|
|
978
|
-
tools.push({
|
|
979
|
-
name: `${toolName}_${builtinNames.context}_use`,
|
|
980
|
-
description: 'Set the active API context (switches all targets at once)',
|
|
981
|
-
inputSchema: {
|
|
982
|
-
type: 'object',
|
|
983
|
-
properties: {
|
|
984
|
-
name: { type: 'string', description: 'Context name to activate' },
|
|
985
|
-
},
|
|
986
|
-
required: ['name'],
|
|
987
|
-
},
|
|
988
|
-
});
|
|
989
|
-
tools.push({
|
|
990
|
-
name: `${toolName}_${builtinNames.context}_current`,
|
|
991
|
-
description: 'Show the currently active API context',
|
|
992
|
-
inputSchema: { type: 'object', properties: {} },
|
|
993
|
-
});
|
|
994
|
-
tools.push({
|
|
995
|
-
name: `${toolName}_${builtinNames.context}_delete`,
|
|
996
|
-
description: 'Delete an API context',
|
|
997
|
-
inputSchema: {
|
|
998
|
-
type: 'object',
|
|
999
|
-
properties: {
|
|
1000
|
-
name: { type: 'string', description: 'Context name to delete' },
|
|
1001
|
-
},
|
|
1002
|
-
required: ['name'],
|
|
1003
|
-
},
|
|
1004
|
-
});
|
|
1005
|
-
tools.push({
|
|
1006
|
-
name: `${toolName}_${builtinNames.auth}_set_token`,
|
|
1007
|
-
description: 'Store a bearer token for the current context (shared across all targets)',
|
|
1008
|
-
inputSchema: {
|
|
1009
|
-
type: 'object',
|
|
1010
|
-
properties: {
|
|
1011
|
-
token: { type: 'string', description: 'Bearer token value' },
|
|
1012
|
-
},
|
|
1013
|
-
required: ['token'],
|
|
1014
|
-
},
|
|
1015
|
-
});
|
|
1016
|
-
tools.push({
|
|
1017
|
-
name: `${toolName}_${builtinNames.auth}_status`,
|
|
1018
|
-
description: 'Show authentication status for all contexts',
|
|
1019
|
-
inputSchema: { type: 'object', properties: {} },
|
|
1020
|
-
});
|
|
1021
|
-
tools.push({
|
|
1022
|
-
name: `${toolName}_${builtinNames.auth}_logout`,
|
|
1023
|
-
description: 'Remove credentials for the current context',
|
|
1024
|
-
inputSchema: { type: 'object', properties: {} },
|
|
1025
|
-
});
|
|
1026
|
-
tools.push({
|
|
1027
|
-
name: `${toolName}_${builtinNames.config}_get`,
|
|
1028
|
-
description: 'Get a config variable value for the current context',
|
|
1029
|
-
inputSchema: {
|
|
1030
|
-
type: 'object',
|
|
1031
|
-
properties: {
|
|
1032
|
-
key: { type: 'string', description: 'Variable name' },
|
|
1033
|
-
},
|
|
1034
|
-
required: ['key'],
|
|
1035
|
-
},
|
|
1036
|
-
});
|
|
1037
|
-
tools.push({
|
|
1038
|
-
name: `${toolName}_${builtinNames.config}_set`,
|
|
1039
|
-
description: 'Set a config variable value for the current context',
|
|
1040
|
-
inputSchema: {
|
|
1041
|
-
type: 'object',
|
|
1042
|
-
properties: {
|
|
1043
|
-
key: { type: 'string', description: 'Variable name' },
|
|
1044
|
-
value: { type: 'string', description: 'Variable value' },
|
|
1045
|
-
},
|
|
1046
|
-
required: ['key', 'value'],
|
|
1047
|
-
},
|
|
1048
|
-
});
|
|
1049
|
-
tools.push({
|
|
1050
|
-
name: `${toolName}_${builtinNames.config}_list`,
|
|
1051
|
-
description: 'List all config variables for the current context',
|
|
1052
|
-
inputSchema: { type: 'object', properties: {} },
|
|
1053
|
-
});
|
|
1054
|
-
tools.push({
|
|
1055
|
-
name: `${toolName}_${builtinNames.config}_delete`,
|
|
1056
|
-
description: 'Delete a config variable for the current context',
|
|
1057
|
-
inputSchema: {
|
|
1058
|
-
type: 'object',
|
|
1059
|
-
properties: {
|
|
1060
|
-
key: { type: 'string', description: 'Variable name to delete' },
|
|
1061
|
-
},
|
|
1062
|
-
required: ['key'],
|
|
1063
|
-
},
|
|
1064
|
-
});
|
|
1065
|
-
for (const tgt of targets) {
|
|
1066
|
-
for (const table of tgt.tables) {
|
|
1067
|
-
const { singularName } = getTableNames(table);
|
|
1068
|
-
const kebab = toKebabCase(singularName);
|
|
1069
|
-
const pk = getPrimaryKeyInfo(table)[0];
|
|
1070
|
-
const scalarFields = getScalarFields(table);
|
|
1071
|
-
const editableFields = getEditableFields(table, registry);
|
|
1072
|
-
const defaultFields = getFieldsWithDefaults(table, registry);
|
|
1073
|
-
const requiredCreateFieldNames = editableFields
|
|
1074
|
-
.filter((f) => !defaultFields.has(f.name))
|
|
1075
|
-
.map((f) => f.name);
|
|
1076
|
-
const prefix = `${toolName}_${tgt.name}_${kebab}`;
|
|
1077
|
-
tools.push({
|
|
1078
|
-
name: `${prefix}_list`,
|
|
1079
|
-
description: `List all ${table.name} records (${tgt.name} target)`,
|
|
1080
|
-
inputSchema: { type: 'object', properties: {} },
|
|
1081
|
-
});
|
|
1082
|
-
tools.push({
|
|
1083
|
-
name: `${prefix}_get`,
|
|
1084
|
-
description: `Get a single ${table.name} record by ${pk.name} (${tgt.name} target)`,
|
|
1085
|
-
inputSchema: {
|
|
1086
|
-
type: 'object',
|
|
1087
|
-
properties: {
|
|
1088
|
-
[pk.name]: {
|
|
1089
|
-
type: gqlTypeToJsonSchemaType(pk.gqlType),
|
|
1090
|
-
description: `${table.name} ${pk.name}`,
|
|
1091
|
-
},
|
|
1092
|
-
},
|
|
1093
|
-
required: [pk.name],
|
|
1094
|
-
},
|
|
1095
|
-
});
|
|
1096
|
-
const createProps = {};
|
|
1097
|
-
for (const f of editableFields) {
|
|
1098
|
-
createProps[f.name] = {
|
|
1099
|
-
type: gqlTypeToJsonSchemaType(cleanTypeName(f.type.gqlType)),
|
|
1100
|
-
description: `${table.name} ${f.name}`,
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
tools.push({
|
|
1104
|
-
name: `${prefix}_create`,
|
|
1105
|
-
description: `Create a new ${table.name} record (${tgt.name} target)`,
|
|
1106
|
-
inputSchema: {
|
|
1107
|
-
type: 'object',
|
|
1108
|
-
properties: createProps,
|
|
1109
|
-
...(requiredCreateFieldNames.length > 0 ? { required: requiredCreateFieldNames } : {}),
|
|
1110
|
-
},
|
|
1111
|
-
});
|
|
1112
|
-
const updateProps = {
|
|
1113
|
-
[pk.name]: {
|
|
1114
|
-
type: gqlTypeToJsonSchemaType(pk.gqlType),
|
|
1115
|
-
description: `${table.name} ${pk.name}`,
|
|
1116
|
-
},
|
|
1117
|
-
};
|
|
1118
|
-
for (const f of editableFields) {
|
|
1119
|
-
updateProps[f.name] = {
|
|
1120
|
-
type: gqlTypeToJsonSchemaType(cleanTypeName(f.type.gqlType)),
|
|
1121
|
-
description: `${table.name} ${f.name}`,
|
|
1122
|
-
};
|
|
1123
|
-
}
|
|
1124
|
-
tools.push({
|
|
1125
|
-
name: `${prefix}_update`,
|
|
1126
|
-
description: `Update an existing ${table.name} record (${tgt.name} target)`,
|
|
1127
|
-
inputSchema: {
|
|
1128
|
-
type: 'object',
|
|
1129
|
-
properties: updateProps,
|
|
1130
|
-
required: [pk.name],
|
|
1131
|
-
},
|
|
1132
|
-
});
|
|
1133
|
-
tools.push({
|
|
1134
|
-
name: `${prefix}_delete`,
|
|
1135
|
-
description: `Delete a ${table.name} record by ${pk.name} (${tgt.name} target)`,
|
|
1136
|
-
inputSchema: {
|
|
1137
|
-
type: 'object',
|
|
1138
|
-
properties: {
|
|
1139
|
-
[pk.name]: {
|
|
1140
|
-
type: gqlTypeToJsonSchemaType(pk.gqlType),
|
|
1141
|
-
description: `${table.name} ${pk.name}`,
|
|
1142
|
-
},
|
|
1143
|
-
},
|
|
1144
|
-
required: [pk.name],
|
|
1145
|
-
},
|
|
1146
|
-
});
|
|
1147
|
-
tools.push({
|
|
1148
|
-
name: `${prefix}_fields`,
|
|
1149
|
-
description: `List available fields for ${table.name} (${tgt.name} target)`,
|
|
1150
|
-
inputSchema: { type: 'object', properties: {} },
|
|
1151
|
-
_meta: {
|
|
1152
|
-
fields: scalarFields.map((f) => ({
|
|
1153
|
-
name: f.name,
|
|
1154
|
-
type: cleanTypeName(f.type.gqlType),
|
|
1155
|
-
editable: editableFields.some((ef) => ef.name === f.name),
|
|
1156
|
-
primaryKey: f.name === pk.name,
|
|
1157
|
-
})),
|
|
1158
|
-
},
|
|
1159
|
-
});
|
|
1160
|
-
}
|
|
1161
|
-
for (const op of tgt.customOperations) {
|
|
1162
|
-
const kebab = toKebabCase(op.name);
|
|
1163
|
-
const flat = flattenArgs(op.args, registry);
|
|
1164
|
-
const props = {};
|
|
1165
|
-
const required = [];
|
|
1166
|
-
for (const a of flat) {
|
|
1167
|
-
props[a.flag] = {
|
|
1168
|
-
type: gqlTypeToJsonSchemaType(a.type),
|
|
1169
|
-
description: a.description || a.flag,
|
|
1170
|
-
};
|
|
1171
|
-
if (a.required) {
|
|
1172
|
-
required.push(a.flag);
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
if (tgt.isAuthTarget && op.kind === 'mutation') {
|
|
1176
|
-
props['save_token'] = {
|
|
1177
|
-
type: 'boolean',
|
|
1178
|
-
description: 'Auto-save returned token to credentials',
|
|
1179
|
-
};
|
|
1180
|
-
}
|
|
1181
|
-
tools.push({
|
|
1182
|
-
name: `${toolName}_${tgt.name}_${kebab}`,
|
|
1183
|
-
description: `${op.description || op.name} (${tgt.name} target)`,
|
|
1184
|
-
inputSchema: {
|
|
1185
|
-
type: 'object',
|
|
1186
|
-
properties: props,
|
|
1187
|
-
...(required.length > 0 ? { required } : {}),
|
|
1188
|
-
},
|
|
1189
|
-
});
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
return tools;
|
|
1193
|
-
}
|
|
1194
770
|
export function generateMultiTargetSkills(input) {
|
|
1195
771
|
const { toolName, builtinNames, targets, registry } = input;
|
|
1196
772
|
const files = [];
|
|
@@ -1350,6 +926,12 @@ export function generateMultiTargetSkills(input) {
|
|
|
1350
926
|
description: mtSkillSpecialDesc,
|
|
1351
927
|
usage: [
|
|
1352
928
|
`${toolName} ${cmd} list`,
|
|
929
|
+
`${toolName} ${cmd} list --where.<field>.<op> <value> --orderBy <values>`,
|
|
930
|
+
`${toolName} ${cmd} list --limit 10 --after <cursor>`,
|
|
931
|
+
`${toolName} ${cmd} find-first --where.<field>.<op> <value>`,
|
|
932
|
+
...(mtSkillSpecialGroups.some((g) => g.category === 'search' || g.category === 'embedding')
|
|
933
|
+
? [`${toolName} ${cmd} search <query>`]
|
|
934
|
+
: []),
|
|
1353
935
|
`${toolName} ${cmd} get --${pk.name} <${cleanTypeName(pk.gqlType)}>`,
|
|
1354
936
|
`${toolName} ${cmd} create ${createFlags}`,
|
|
1355
937
|
`${toolName} ${cmd} update --${pk.name} <${cleanTypeName(pk.gqlType)}> ${editableFields.map((f) => `[--${f.name} <${cleanTypeName(f.type.gqlType)}>]`).join(' ')}`,
|
|
@@ -1357,9 +939,31 @@ export function generateMultiTargetSkills(input) {
|
|
|
1357
939
|
],
|
|
1358
940
|
examples: [
|
|
1359
941
|
{
|
|
1360
|
-
description: `List
|
|
942
|
+
description: `List ${singularName} records`,
|
|
1361
943
|
code: [`${toolName} ${cmd} list`],
|
|
1362
944
|
},
|
|
945
|
+
{
|
|
946
|
+
description: `List ${singularName} records with pagination`,
|
|
947
|
+
code: [`${toolName} ${cmd} list --limit 10 --offset 0`],
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
description: `List ${singularName} records with cursor pagination`,
|
|
951
|
+
code: [`${toolName} ${cmd} list --limit 10 --after <cursor>`],
|
|
952
|
+
},
|
|
953
|
+
{
|
|
954
|
+
description: `Find first matching ${singularName}`,
|
|
955
|
+
code: [`${toolName} ${cmd} find-first --where.${pk.name}.equalTo <value>`],
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
description: `List ${singularName} records with filtering and ordering`,
|
|
959
|
+
code: [`${toolName} ${cmd} list --where.${pk.name}.equalTo <value> --orderBy ${pk.name.replace(/([A-Z])/g, '_$1').toUpperCase()}_ASC`],
|
|
960
|
+
},
|
|
961
|
+
...(mtSkillSpecialGroups.some((g) => g.category === 'search' || g.category === 'embedding')
|
|
962
|
+
? [{
|
|
963
|
+
description: `Search ${singularName} records`,
|
|
964
|
+
code: [`${toolName} ${cmd} search "query text" --limit 10 --fields id,searchScore`],
|
|
965
|
+
}]
|
|
966
|
+
: []),
|
|
1363
967
|
{
|
|
1364
968
|
description: `Create a ${singularName}`,
|
|
1365
969
|
code: [
|
|
@@ -58,9 +58,9 @@ export { generateConfigCommand } from './config-command-generator';
|
|
|
58
58
|
export { generateHelpersFile } from './helpers-generator';
|
|
59
59
|
export type { HelpersGeneratorInput } from './helpers-generator';
|
|
60
60
|
export { generateContextCommand, generateAuthCommand, generateMultiTargetContextCommand, generateAuthCommandWithName, } from './infra-generator';
|
|
61
|
-
export { generateReadme, generateAgentsDocs,
|
|
61
|
+
export { generateReadme, generateAgentsDocs, generateSkills, generateMultiTargetReadme, generateMultiTargetAgentsDocs, generateMultiTargetSkills, } from './docs-generator';
|
|
62
62
|
export type { MultiTargetDocsInput } from './docs-generator';
|
|
63
63
|
export { resolveDocsConfig } from '../docs-utils';
|
|
64
|
-
export type { GeneratedDocFile
|
|
64
|
+
export type { GeneratedDocFile } from '../docs-utils';
|
|
65
65
|
export { generateUtilsFile, generateEntryPointFile } from './utils-generator';
|
|
66
66
|
export type { GeneratedFile, MultiTargetExecutorInput } from './executor-generator';
|
|
@@ -171,6 +171,6 @@ export { generateCommandMap, generateMultiTargetCommandMap } from './command-map
|
|
|
171
171
|
export { generateConfigCommand } from './config-command-generator';
|
|
172
172
|
export { generateHelpersFile } from './helpers-generator';
|
|
173
173
|
export { generateContextCommand, generateAuthCommand, generateMultiTargetContextCommand, generateAuthCommandWithName, } from './infra-generator';
|
|
174
|
-
export { generateReadme, generateAgentsDocs,
|
|
174
|
+
export { generateReadme, generateAgentsDocs, generateSkills, generateMultiTargetReadme, generateMultiTargetAgentsDocs, generateMultiTargetSkills, } from './docs-generator';
|
|
175
175
|
export { resolveDocsConfig } from '../docs-utils';
|
|
176
176
|
export { generateUtilsFile, generateEntryPointFile } from './utils-generator';
|