MCPcopy
hub / github.com/vercel-labs/just-bash / extractReadmeCommands

Function extractReadmeCommands

packages/just-bash/src/readme.test.ts:59–80  ·  view source on GitHub ↗

* Extract command names from README "Supported Commands" section

(readme: string)

Source from the content-addressed store, hash-verified

57 * Extract command names from README "Supported Commands" section
58 */
59function extractReadmeCommands(readme: string): Set<string> {
60 const commands = new Set<string>();
61
62 // Find the "Supported Commands" section (stop at "All commands support")
63 const supportedMatch = readme.match(
64 /Supported Commands[\s\S]*?\n([\s\S]*?)(?=\nAll commands support|\n## [A-Z]|\n---|\$)/,
65 );
66 if (!supportedMatch) {
67 throw new Error("Could not find 'Supported Commands' section in README");
68 }
69
70 const section = supportedMatch[1];
71
72 // Extract all backtick-quoted command names
73 // Matches: `cmd`, `cmd` (+ `alias1`, `alias2`)
74 const cmdPattern = /`([a-z0-9_-]+)`/g;
75 for (const match of section.matchAll(cmdPattern)) {
76 commands.add(match[1]);
77 }
78
79 return commands;
80}
81
82/**
83 * Extract command names from AGENTS.npm.md "Available Commands" section

Callers 1

readme.test.tsFile · 0.85

Calls 2

matchMethod · 0.65
matchAllMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…