MCPcopy Create free account
hub / github.com/pbakaus/impeccable / projectRootFromWorkspacePattern

Function projectRootFromWorkspacePattern

skill/scripts/context.mjs:628–641  ·  view source on GitHub ↗
(repoRoot, relSegments, rawPattern)

Source from the content-addressed store, hash-verified

626}
627
628function projectRootFromWorkspacePattern(repoRoot, relSegments, rawPattern) {
629 const pattern = normalizeWorkspacePattern(rawPattern);
630 if (!pattern || pattern.startsWith('!')) return null;
631 const patternSegments = pattern.split('/').filter(Boolean);
632 if (!patternSegments.length) return null;
633 if (patternSegments.includes('**')) {
634 return projectRootFromDoubleStarPattern(repoRoot, relSegments, patternSegments);
635 }
636 if (relSegments.length < patternSegments.length) return null;
637 for (let i = 0; i < patternSegments.length; i++) {
638 if (!segmentMatches(patternSegments[i], relSegments[i])) return null;
639 }
640 return path.join(repoRoot, ...relSegments.slice(0, patternSegments.length));
641}
642
643function projectRootFromDoubleStarPattern(repoRoot, relSegments, patternSegments) {
644 const firstGlobIndex = patternSegments.findIndex((segment) => segment.includes('*'));

Callers 1

Calls 3

segmentMatchesFunction · 0.70

Tested by

no test coverage detected