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 | 16x 2290x 2290x 1801x 1801x 1801x 1984x 1801x 1984x 1984x 1801x 113x 1688x 16x 150x | /**
* Description Utilities for Tool Cross-References
*
* Provides dynamic resolution of "Related:" sections in tool descriptions.
* References to unavailable tools (disabled via USE_*, GITLAB_DENIED_TOOLS_REGEX,
* tier/version gating, or all-actions-denied) are automatically stripped.
*/
/**
* Strip "Related:" section references to unavailable tools.
* If all referenced tools are unavailable, the entire "Related:" clause is removed.
*
* Format: "... Related: tool_name purpose, tool_name2 purpose."
* Multiple items separated by commas. Each starts with a tool name (browse_ or manage_ prefix).
*/
export function resolveRelatedReferences(description: string, availableTools: Set<string>): string {
const relatedMatch = description.match(/\s*Related:\s*(.+?)\.?\s*$/);
if (!relatedMatch) return description;
const matchIndex = relatedMatch.index ?? description.length;
const baseDescription = description.substring(0, matchIndex);
const relatedContent = relatedMatch[1];
// Split by comma, keep only items whose tool is available
const items = relatedContent.split(",").map(s => s.trim());
const available = items.filter(item => {
const toolRef = item.match(/^((?:browse|manage)_\w+)\b/);
return toolRef && availableTools.has(toolRef[1]);
});
if (available.length === 0) {
return baseDescription.trimEnd();
}
return `${baseDescription.trimEnd()} Related: ${available.join(", ")}.`;
}
/**
* Remove the entire "Related:" section from a description.
* Used when GITLAB_CROSS_REFS=false to strip all cross-reference hints.
*
* Only matches "Related:" as a section marker (capital R).
* Does not affect lowercase "related" in normal description text.
*/
export function stripRelatedSection(description: string): string {
return description.replace(/\s*Related:\s*(.+?)\.?\s*$/, "").trimEnd();
}
|