UNPKG

@withpica/mcp-server

Version:

MCP Server for withPICA — enables AI assistants to interact with your withPICA music catalog

84 lines • 2.7 kB
// Copyright (c) 2025-2026 Withpica Ltd. All rights reserved. export const CHANGELOG_SECTION_NAMES = [ "Added", "Changed", "Fixed", "Removed", "Security", "Deprecated", ]; const HEADING_RE = /^##\s+\[([^\]]+)\](?:\s*-\s*(\d{4}-\d{2}-\d{2}))?\s*$/; const SECTION_RE = /^###\s+(\w+)\s*$/; const BULLET_RE = /^-\s+(.*)$/; export function parseChangelogText(text) { const lines = text.split("\n"); const entries = []; let current = null; let currentSection = null; let currentBullet = null; const flush = (endLine) => { if (current && current.version !== "Unreleased") { current.markdown = lines .slice(current._start, endLine) .join("\n") .trimEnd(); const { _start, ...rest } = current; entries.push(rest); } current = null; currentSection = null; currentBullet = null; }; for (let i = 0; i < lines.length; i++) { const line = lines[i]; const headingMatch = line.match(HEADING_RE); if (headingMatch) { flush(i); current = { version: headingMatch[1], date: headingMatch[2] ?? null, sections: {}, markdown: "", _start: i, }; currentSection = null; continue; } if (!current) continue; const sectionMatch = line.match(SECTION_RE); if (sectionMatch) { const name = sectionMatch[1]; if (CHANGELOG_SECTION_NAMES.includes(name)) { currentSection = name; if (!current.sections[name]) current.sections[name] = []; } else { currentSection = null; } currentBullet = null; continue; } const bulletMatch = line.match(BULLET_RE); if (bulletMatch && currentSection) { const arr = current.sections[currentSection]; arr.push(bulletMatch[1].trim()); currentBullet = { entry: current, section: currentSection, index: arr.length - 1, }; continue; } if (currentBullet && line.startsWith(" ") && line.trim().length > 0) { const arr = currentBullet.entry.sections[currentBullet.section]; arr[currentBullet.index] = `${arr[currentBullet.index]} ${line.trim()}`; continue; } currentBullet = null; } flush(lines.length); return entries; } //# sourceMappingURL=changelog.js.map