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

Function extractRemoteSlugPatterns

test/helpers/skill-parser.ts:145–173  ·  view source on GitHub ↗
(rootDir: string, subdirs: string[])

Source from the content-addressed store, hash-verified

143 * Returns a Map from filename → array of full assignment lines found.
144 */
145export function extractRemoteSlugPatterns(rootDir: string, subdirs: string[]): Map<string, string[]> {
146 const results = new Map<string, string[]>();
147 const pattern = /^REMOTE_SLUG=\$\(.*\)$/;
148
149 for (const subdir of subdirs) {
150 const dir = path.join(rootDir, subdir);
151 if (!fs.existsSync(dir)) continue;
152
153 const files = fs.readdirSync(dir).filter(f => f.endsWith('.md'));
154 for (const file of files) {
155 const filePath = path.join(dir, file);
156 const content = fs.readFileSync(filePath, 'utf-8');
157 const matches: string[] = [];
158
159 for (const line of content.split('\n')) {
160 const trimmed = line.trim();
161 if (pattern.test(trimmed)) {
162 matches.push(trimmed);
163 }
164 }
165
166 if (matches.length > 0) {
167 results.set(`${subdir}/${file}`, matches);
168 }
169 }
170 }
171
172 return results;
173}
174
175/**
176 * Parse a markdown weight table anchored to a "### Weights" heading.

Callers 1

Calls 2

setMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected