MCPcopy Create free account
hub / github.com/garrytan/gstack / applyHostRewrites

Function applyHostRewrites

scripts/gen-skill-docs.ts:648–659  ·  view source on GitHub ↗

* Apply a host's configured path + tool rewrites. Extracted so both SKILL.md * (via processExternalHost) and section files (via processSectionTemplate) get * identical per-host treatment — a section's cross-references must rewrite the * same way the parent skill's do, or external hosts get wrong

(content: string, hostConfig: HostConfig)

Source from the content-addressed store, hash-verified

646 * same way the parent skill's do, or external hosts get wrong paths.
647 */
648function applyHostRewrites(content: string, hostConfig: HostConfig): string {
649 let result = content;
650 for (const rewrite of hostConfig.pathRewrites) {
651 result = result.replaceAll(rewrite.from, rewrite.to);
652 }
653 if (hostConfig.toolRewrites) {
654 for (const [from, to] of Object.entries(hostConfig.toolRewrites)) {
655 result = result.replaceAll(from, to);
656 }
657 }
658 return result;
659}
660
661/**
662 * Resolve {{PLACEHOLDER}} / {{NAME:arg}} tokens against the RESOLVERS registry,

Callers 2

processExternalHostFunction · 0.85
processSectionTemplateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected