Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | 3x 3x 3x 69x 69x 32x 55x 55x 50x 32x 37x 37x 37x 68x 56x 37x 3x 16x 16x 16x 16x 16x 17x 17x 17x 17x 16x 16x 3x 12x 11x 3x 1x 1x 1x 2x 3x | import { RegistryManager } from '../registry-manager.js';
import type { ToolDefinition } from '../types.js';
export interface JsonSchemaProperty {
type?: string;
properties?: Record<string, JsonSchemaProperty>;
oneOf?: JsonSchemaProperty[];
enum?: unknown[];
const?: unknown;
description?: string;
[key: string]: unknown;
}
export interface ActionInfo {
name: string;
description: string;
}
const ACTION_DESCRIPTIONS: Record<string, string> = {
list: 'List items with filtering and pagination',
get: 'Get a single item by ID',
create: 'Create a new item',
update: 'Update an existing item',
delete: 'Delete an item',
search: 'Search for items',
diffs: 'Get file changes/diffs',
compare: 'Compare two branches or commits',
merge: 'Merge a merge request',
approve: 'Approve a merge request',
unapprove: 'Remove approval from a merge request',
rebase: 'Rebase a merge request',
cancel: 'Cancel a running operation',
retry: 'Retry a failed operation',
play: 'Run a manual job',
publish: 'Publish draft notes',
drafts: 'List draft notes',
draft: 'Get a single draft note',
resolve: 'Resolve a discussion thread',
unresolve: 'Unresolve a discussion thread',
note: 'Add a note/comment',
mark_done: 'Mark as done',
mark_pending: 'Mark as pending',
disable: 'Disable the integration',
test: 'Test a webhook',
read: 'Read item details',
};
/** Action names and descriptions used by both documentation and publication metrics. */
export function extractActions(schema: JsonSchemaProperty): ActionInfo[] {
const actions: ActionInfo[] = [];
if (Array.isArray(schema.oneOf)) {
for (const branch of schema.oneOf) {
const action = branch.properties?.action;
if (typeof action?.const === 'string') {
actions.push({
name: action.const,
description:
action.description ??
ACTION_DESCRIPTIONS[action.const] ??
`Perform ${action.const} operation`,
});
}
}
return actions;
}
const action = schema.properties?.action;
const names = Array.isArray(action?.enum) ? action.enum : [action?.const];
for (const name of names) {
if (typeof name === 'string')
actions.push({
name,
description:
(Array.isArray(action?.enum) ? undefined : action?.description) ??
ACTION_DESCRIPTIONS[name] ??
`Perform ${name} operation`,
});
}
return actions;
}
export interface CatalogMetrics {
toolCount: number;
cqrsToolCount: number;
helperToolCount: number;
actionCount: number;
/** Complete registry groups, including core/context, not configurable settings switches. */
toolGroupCount: number;
readonlyToolCount: number;
description: string;
}
/** Count declared actions, not schema variants, and use each registry's read-only policy. */
export function measureCatalog(catalog: {
tools: ToolDefinition[];
toolGroupCount: number;
readOnlyToolNames: string[];
}): CatalogMetrics {
const readOnly = new Set(catalog.readOnlyToolNames);
let actionCount = 0;
let cqrsToolCount = 0;
let readonlyToolCount = 0;
for (const tool of catalog.tools) {
const names = new Set(extractActions(tool.inputSchema).map((action) => action.name));
actionCount += names.size;
if (names.size > 0) cqrsToolCount++;
if (readOnly.has(tool.name)) readonlyToolCount++;
}
const toolCount = catalog.tools.length;
return {
toolCount,
cqrsToolCount,
helperToolCount: toolCount - cqrsToolCount,
actionCount,
toolGroupCount: catalog.toolGroupCount,
readonlyToolCount,
description: `${toolCount} tools, ${actionCount} typed actions, ${catalog.toolGroupCount} registry groups`,
};
}
export function loadToolCatalog() {
const catalog = RegistryManager.getInstance().getUnfilteredCatalog();
return {
tools: catalog.tools,
metrics: measureCatalog(catalog),
readOnlyToolNames: catalog.readOnlyToolNames,
};
}
// Build-time input for the release and MCPB scripts, never an instance-filtered catalog.
export function main(): void {
const { tools, metrics, readOnlyToolNames } = loadToolCatalog();
const readOnly = new Set(readOnlyToolNames);
console.log(
JSON.stringify({
metrics,
tools: tools.map((tool) => ({
name: tool.name,
description: tool.description,
tier: tool.requirements?.default.tier,
readOnly: readOnly.has(tool.name),
})),
}),
);
}
Iif (require.main === module) main();
|