(content: string)
| 87 | } |
| 88 | |
| 89 | function parseReadme(content: string): ParsedExtension[] { |
| 90 | const allExtensions: ParsedExtension[] = [] |
| 91 | |
| 92 | // Split by sections |
| 93 | const sections = [ |
| 94 | { name: "plugins", header: "## Plugins" }, |
| 95 | { name: "themes", header: "## Themes" }, |
| 96 | { name: "agents", header: "## Agents" }, |
| 97 | { name: "projects", header: "## Projects" }, |
| 98 | { name: "resources", header: "## Resources" }, |
| 99 | ] |
| 100 | |
| 101 | for (const section of sections) { |
| 102 | const startIdx = content.indexOf(section.header) |
| 103 | if (startIdx === -1) { |
| 104 | console.log(`Section ${section.name} not found`) |
| 105 | continue |
| 106 | } |
| 107 | |
| 108 | // Find the next section or end |
| 109 | let endIdx = content.length |
| 110 | for (const other of sections) { |
| 111 | if (other.name === section.name) continue |
| 112 | const otherIdx = content.indexOf(other.header, startIdx + section.header.length) |
| 113 | if (otherIdx !== -1 && otherIdx < endIdx) { |
| 114 | endIdx = otherIdx |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | // Also check for "---" separator |
| 119 | const separatorIdx = content.indexOf("\n---\n", startIdx + section.header.length) |
| 120 | if (separatorIdx !== -1 && separatorIdx < endIdx) { |
| 121 | endIdx = separatorIdx |
| 122 | } |
| 123 | |
| 124 | const sectionContent = content.slice(startIdx, endIdx) |
| 125 | console.log(`Parsing section ${section.name}: ${sectionContent.length} chars`) |
| 126 | const parsed = parseMarkdownTable(sectionContent, section.name) |
| 127 | console.log(` Found ${parsed.length} items`) |
| 128 | allExtensions.push(...parsed) |
| 129 | } |
| 130 | |
| 131 | return allExtensions |
| 132 | } |
| 133 | |
| 134 | async function fetchReadme(): Promise<string> { |
| 135 | console.log("Fetching awesome-opencode README...") |
no test coverage detected