* Extract command names from README "Supported Commands" section
(readme: string)
| 57 | * Extract command names from README "Supported Commands" section |
| 58 | */ |
| 59 | function 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 |
no test coverage detected
searching dependent graphs…