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

Function onePass

scripts/gen-skill-docs.ts:677–688  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

675 // section generation so both paths get the same gbrain-aware behavior.
676 const suppressed = effectiveSuppressedResolvers(hostConfig);
677 const onePass = (input: string): string =>
678 input.replace(/\{\{(\w+(?::[^}]+)?)\}\}/g, (_match, fullKey) => {
679 const parts = fullKey.split(':');
680 const resolverName = parts[0];
681 const args = parts.slice(1);
682 if (suppressed.has(resolverName)) return '';
683 const entry = RESOLVERS[resolverName];
684 if (!entry) throw new Error(`Unknown placeholder {{${resolverName}}} in ${relTmplPath}`);
685 const { resolve, appliesTo } = unwrapResolver(entry);
686 if (appliesTo && !appliesTo(ctx)) return '';
687 return args.length > 0 ? resolve(ctx, args) : resolve(ctx);
688 });
689
690 // Multi-pass: a resolver may emit content that itself contains {{TOKENS}} — the
691 // {{SECTION:id}} resolver inlines a section template (with its own resolvers)

Callers 1

resolvePlaceholdersFunction · 0.85

Calls 1

unwrapResolverFunction · 0.90

Tested by

no test coverage detected