@mrsf/cli 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/browser.ts", "../src/lib/fuzzy.ts", "../src/lib/identity.ts", "../src/lib/reanchor-core.ts", "../src/lib/validate-core.ts", "../mrsf.schema.json", "../src/lib/schema.ts"],
4
+ "sourcesContent": ["import * as fuzzy from \"./lib/fuzzy.js\";\nimport * as identity from \"./lib/identity.js\";\nimport * as reanchorCore from \"./lib/reanchor-core.js\";\nimport * as validateCore from \"./lib/validate-core.js\";\nimport { mrsfSchema } from \"./lib/schema.js\";\n\nexport type {\n AnchorPosition,\n Comment,\n DiffHunk,\n FuzzyCandidate,\n MrsfDocument,\n ReanchorResult,\n ReanchorStatus,\n} from \"./lib/types.js\";\nexport type { ParsedAuthor } from \"./lib/identity.js\";\n\nexport const combinedScore = fuzzy.combinedScore;\nexport const exactMatch = fuzzy.exactMatch;\nexport const fuzzySearch = fuzzy.fuzzySearch;\nexport const levenshteinScore = fuzzy.levenshteinScore;\nexport const normalizedMatch = fuzzy.normalizedMatch;\nexport const tokenLcsScore = fuzzy.tokenLcsScore;\n\nexport const applyReanchorResults = reanchorCore.applyReanchorResults;\nexport const DEFAULT_THRESHOLD = reanchorCore.DEFAULT_THRESHOLD;\nexport const HIGH_THRESHOLD = reanchorCore.HIGH_THRESHOLD;\nexport const reanchorComment = reanchorCore.reanchorComment;\nexport const reanchorDocumentLines = reanchorCore.reanchorDocumentLines;\nexport const reanchorDocumentText = reanchorCore.reanchorDocumentText;\nexport const resolveAnchor = reanchorCore.resolveAnchor;\nexport const toReanchorLines = reanchorCore.toReanchorLines;\n\nexport const validateDocument = validateCore.validateDocument;\nexport { mrsfSchema };\n\nexport const formatAuthor = identity.formatAuthor;\nexport const parseAuthor = identity.parseAuthor;\nexport const newCommentId = identity.newCommentId;\n", "/**\n * MRSF Fuzzy Matching Engine\n *\n * Provides exact, normalized, token-level LCS, and character-level\n * Levenshtein matching for re-anchoring selected_text.\n */\n\nimport { distance as levenshtein } from \"fastest-levenshtein\";\nimport type { FuzzyCandidate } from \"./types.js\";\n\n// ---------------------------------------------------------------------------\n// Exact matching\n// ---------------------------------------------------------------------------\n\n/**\n * Find all exact occurrences of `needle` in lines (1-based array).\n */\nexport function exactMatch(\n lines: string[],\n needle: string,\n): FuzzyCandidate[] {\n if (!needle) return [];\n\n const results: FuzzyCandidate[] = [];\n const needleLines = needle.split(\"\\n\");\n const needleLineCount = needleLines.length;\n\n // Slide a window across the document\n for (let startLine = 1; startLine <= lines.length - needleLineCount; startLine++) {\n // Build the text for this window\n const windowLines = lines.slice(startLine, startLine + needleLineCount);\n const windowText = windowLines.join(\"\\n\");\n\n // Check if the needle appears anywhere within this window (for single-line)\n if (needleLineCount === 1) {\n let col = 0;\n const line = windowLines[0];\n while (col < line.length) {\n const idx = line.indexOf(needle, col);\n if (idx === -1) break;\n results.push({\n text: needle,\n line: startLine,\n endLine: startLine,\n startColumn: idx,\n endColumn: idx + needle.length,\n score: 1.0,\n });\n col = idx + 1;\n }\n } else {\n // Multi-line: check if the window contains the exact needle\n const idx = windowText.indexOf(needle);\n if (idx !== -1) {\n // Calculate start column\n const beforeMatch = windowText.slice(0, idx);\n const linesBeforeEnd = beforeMatch.split(\"\\n\");\n const startCol = linesBeforeEnd[linesBeforeEnd.length - 1].length;\n\n // Calculate end column\n const afterMatch = needle.split(\"\\n\");\n const endCol = afterMatch[afterMatch.length - 1].length;\n if (startCol === 0 || linesBeforeEnd.length === 1) {\n results.push({\n text: needle,\n line: startLine + linesBeforeEnd.length - 1,\n endLine: startLine + linesBeforeEnd.length - 1 + afterMatch.length - 1,\n startColumn: startCol,\n endColumn: endCol,\n score: 1.0,\n });\n }\n }\n }\n }\n\n return results;\n}\n\n// ---------------------------------------------------------------------------\n// Normalized matching (collapse whitespace)\n// ---------------------------------------------------------------------------\n\nfunction normalize(text: string): string {\n return text.replace(/\\s+/g, \" \").trim();\n}\n\n/**\n * Find matches after normalizing whitespace.\n */\nexport function normalizedMatch(\n lines: string[],\n needle: string,\n): FuzzyCandidate[] {\n const normNeedle = normalize(needle);\n if (!normNeedle) return [];\n\n const results: FuzzyCandidate[] = [];\n\n // Try expanding windows of varying sizes\n const needleLineEstimate = needle.split(\"\\n\").length;\n const minWindow = Math.max(1, needleLineEstimate - 1);\n const maxWindow = Math.min(lines.length - 1, needleLineEstimate + 2);\n\n for (let winSize = minWindow; winSize <= maxWindow; winSize++) {\n for (let startLine = 1; startLine + winSize - 1 < lines.length; startLine++) {\n const windowLines = lines.slice(startLine, startLine + winSize);\n const windowText = windowLines.join(\"\\n\");\n const normWindow = normalize(windowText);\n\n if (normWindow.includes(normNeedle)) {\n results.push({\n text: windowText,\n line: startLine,\n endLine: startLine + winSize - 1,\n startColumn: 0,\n endColumn: windowLines[windowLines.length - 1].length,\n score: 0.95,\n });\n }\n }\n }\n\n return deduplicateCandidates(results);\n}\n\n// ---------------------------------------------------------------------------\n// Token-level LCS\n// ---------------------------------------------------------------------------\n\nfunction tokenize(text: string): string[] {\n return text.split(/\\s+/).filter((t) => t.length > 0);\n}\n\n/**\n * Longest Common Subsequence length of two token arrays.\n */\nfunction lcsLength(a: string[], b: string[]): number {\n const m = a.length;\n const n = b.length;\n // Optimize: use two rows instead of full matrix\n let prev = new Array<number>(n + 1).fill(0);\n let curr = new Array<number>(n + 1).fill(0);\n\n for (let i = 1; i <= m; i++) {\n for (let j = 1; j <= n; j++) {\n if (a[i - 1] === b[j - 1]) {\n curr[j] = prev[j - 1] + 1;\n } else {\n curr[j] = Math.max(prev[j], curr[j - 1]);\n }\n }\n [prev, curr] = [curr, prev];\n curr.fill(0);\n }\n\n return prev[n];\n}\n\n/**\n * Score two texts using token-level LCS.\n * Returns 0.0\u20131.0.\n */\nexport function tokenLcsScore(a: string, b: string): number {\n const tokA = tokenize(a);\n const tokB = tokenize(b);\n if (tokA.length === 0 && tokB.length === 0) return 1.0;\n if (tokA.length === 0 || tokB.length === 0) return 0.0;\n const lcs = lcsLength(tokA, tokB);\n return lcs / Math.max(tokA.length, tokB.length);\n}\n\n// ---------------------------------------------------------------------------\n// Character-level Levenshtein score\n// ---------------------------------------------------------------------------\n\n/**\n * Normalized Levenshtein similarity 0.0\u20131.0.\n */\nexport function levenshteinScore(a: string, b: string): number {\n if (a.length === 0 && b.length === 0) return 1.0;\n const maxLen = Math.max(a.length, b.length);\n if (maxLen === 0) return 1.0;\n const dist = levenshtein(a, b);\n return 1 - dist / maxLen;\n}\n\n// ---------------------------------------------------------------------------\n// Combined fuzzy scoring\n// ---------------------------------------------------------------------------\n\n/**\n * Compute a combined similarity score between two text fragments.\n * Blends token LCS (structural) and Levenshtein (character-level).\n */\nexport function combinedScore(needle: string, candidate: string): number {\n const tScore = tokenLcsScore(needle, candidate);\n\n // Full Levenshtein is expensive for long texts; only use for short ones\n let lScore: number;\n if (needle.length < 500 && candidate.length < 500) {\n lScore = levenshteinScore(needle, candidate);\n } else {\n lScore = tScore; // fall back to token score only\n }\n\n // Weight: 60% token LCS, 40% Levenshtein\n return tScore * 0.6 + lScore * 0.4;\n}\n\n// ---------------------------------------------------------------------------\n// Fuzzy search across document\n// ---------------------------------------------------------------------------\n\n/**\n * Search the document for fuzzy matches of `needle`.\n *\n * @param lines 1-based line array (index 0 unused).\n * @param needle The original selected_text.\n * @param threshold Minimum score to include (0.0\u20131.0).\n * @param hintLine Optional original line number for proximity scoring.\n */\nexport function fuzzySearch(\n lines: string[],\n needle: string,\n threshold: number = 0.6,\n hintLine?: number,\n): FuzzyCandidate[] {\n if (!needle) return [];\n\n const needleLines = needle.split(\"\\n\");\n const needleLineCount = needleLines.length;\n const candidates: FuzzyCandidate[] = [];\n\n // Window sizes: \u00B130% of original line count, minimum 1\n const minWindow = Math.max(1, Math.floor(needleLineCount * 0.7));\n const maxWindow = Math.min(\n lines.length - 1,\n Math.ceil(needleLineCount * 1.3) + 1,\n );\n\n for (let winSize = minWindow; winSize <= maxWindow; winSize++) {\n for (let startLine = 1; startLine + winSize - 1 < lines.length; startLine++) {\n const windowLines = lines.slice(startLine, startLine + winSize);\n const windowText = windowLines.join(\"\\n\");\n\n const score = combinedScore(needle, windowText);\n\n if (score >= threshold) {\n candidates.push({\n text: windowText,\n line: startLine,\n endLine: startLine + winSize - 1,\n startColumn: 0,\n endColumn: windowLines[windowLines.length - 1].length,\n score,\n });\n }\n }\n }\n\n // For single-line needles, also try substring matching within each line\n if (needleLineCount === 1 && needle.length < 200) {\n for (let lineNum = 1; lineNum < lines.length; lineNum++) {\n const line = lines[lineNum];\n if (!line) continue;\n\n // Sliding window within line\n const winLen = needle.length;\n const minWinLen = Math.max(3, Math.floor(winLen * 0.7));\n const maxWinLen = Math.min(line.length, Math.ceil(winLen * 1.3));\n\n for (let len = minWinLen; len <= maxWinLen; len++) {\n for (let col = 0; col + len <= line.length; col++) {\n const sub = line.substring(col, col + len);\n const score = combinedScore(needle, sub);\n if (score >= threshold) {\n candidates.push({\n text: sub,\n line: lineNum,\n endLine: lineNum,\n startColumn: col,\n endColumn: col + len,\n score,\n });\n }\n }\n }\n }\n }\n\n // Deduplicate and sort\n let deduped = deduplicateCandidates(candidates);\n\n // Apply proximity bonus if hintLine is provided\n if (hintLine != null) {\n deduped = deduped.map((c) => {\n const dist = Math.abs(c.line - hintLine);\n // Small bonus for proximity (up to 0.1 for exact line match)\n const proximityBonus = 0.1 * Math.max(0, 1 - dist / 50);\n return { ...c, score: Math.min(1.0, c.score + proximityBonus) };\n });\n }\n\n return deduped.sort((a, b) => b.score - a.score);\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction deduplicateCandidates(\n candidates: FuzzyCandidate[],\n): FuzzyCandidate[] {\n const seen = new Map<string, FuzzyCandidate>();\n for (const c of candidates) {\n const key = `${c.line}:${c.startColumn}:${c.endLine}:${c.endColumn}`;\n const existing = seen.get(key);\n if (!existing || c.score > existing.score) {\n seen.set(key, c);\n }\n }\n return Array.from(seen.values());\n}\n", "import { v4 as uuidv4 } from \"uuid\";\n\nexport interface ParsedAuthor {\n name: string;\n handle?: string;\n}\n\nexport function formatAuthor(name: string, handle?: string): string {\n const trimmedName = name.trim();\n const trimmedHandle = handle?.trim();\n return trimmedHandle ? `${trimmedName} (${trimmedHandle})` : trimmedName;\n}\n\nexport function parseAuthor(author: string): ParsedAuthor {\n const trimmed = author.trim();\n const match = /^(.*?)\\s*\\(([^()]*)\\)\\s*$/.exec(trimmed);\n if (!match) return { name: trimmed };\n\n const name = match[1].trim();\n const handle = match[2].trim();\n return handle ? { name, handle } : { name };\n}\n\n/**\n * Create a collision-resistant MRSF comment id.\n * ULID is also permitted by the spec; UUIDv4 is the default for this package.\n */\nexport function newCommentId(): string {\n return uuidv4();\n}\n", "import type {\n AnchorPosition,\n Comment,\n DiffHunk,\n MrsfDocument,\n ReanchorResult,\n} from \"./types.js\";\nimport {\n exactMatch,\n fuzzySearch,\n normalizedMatch,\n} from \"./fuzzy.js\";\n\nexport const HIGH_THRESHOLD = 0.8;\nexport const DEFAULT_THRESHOLD = 0.6;\n\nexport function toReanchorLines(documentText: string): string[] {\n return [\"\", ...documentText.replace(/\\r\\n/g, \"\\n\").split(\"\\n\")];\n}\n\nexport function reanchorComment(\n comment: Comment,\n documentLines: string[],\n opts: {\n diffHunks?: DiffHunk[];\n threshold?: number;\n commitIsStale?: boolean;\n } = {},\n): ReanchorResult {\n const threshold = opts.threshold ?? DEFAULT_THRESHOLD;\n const commentId = comment.id;\n const selectedText = comment.selected_text;\n\n if (!selectedText && comment.line == null) {\n return {\n commentId,\n status: \"anchored\",\n score: 1.0,\n reason: \"Document-level comment (no anchor needed).\",\n };\n }\n\n if (comment.line != null && opts.diffHunks?.length) {\n const { shift, modified } = getLineShift(opts.diffHunks, comment.line);\n\n if (!selectedText) {\n const shiftedLine = comment.line + shift;\n const lineSpan =\n comment.end_line != null ? comment.end_line - comment.line : 0;\n const shiftedEndLine =\n comment.end_line != null ? shiftedLine + lineSpan : undefined;\n return {\n commentId,\n status: shift === 0 ? \"anchored\" : \"shifted\",\n score: 1.0,\n newLine: shiftedLine,\n newEndLine: shiftedEndLine,\n reason:\n shift === 0\n ? \"Line-only comment unchanged (diff confirms position).\"\n : `Line-only comment shifted by ${shift > 0 ? \"+\" : \"\"}${shift} line(s) via diff.`,\n };\n }\n\n if (!modified) {\n const shiftedLine = comment.line + shift;\n const lineSpan =\n comment.end_line != null ? comment.end_line - comment.line : 0;\n const shiftedEndLine =\n comment.end_line != null ? shiftedLine + lineSpan : undefined;\n\n const textAtShifted = extractText(\n documentLines,\n shiftedLine,\n shiftedEndLine,\n comment.start_column,\n comment.end_column,\n );\n\n if (textAtShifted === selectedText) {\n return {\n commentId,\n status: shift === 0 ? \"anchored\" : \"shifted\",\n score: 1.0,\n newLine: shiftedLine,\n newEndLine: shiftedEndLine,\n reason:\n shift === 0\n ? \"Diff confirms text unchanged at original position.\"\n : `Diff shifted by ${shift > 0 ? \"+\" : \"\"}${shift} line(s).`,\n };\n }\n }\n }\n\n if (selectedText) {\n const exactCandidates = exactMatch(documentLines, selectedText);\n\n if (exactCandidates.length === 1) {\n const candidate = exactCandidates[0];\n return {\n commentId,\n status: \"anchored\",\n score: 1.0,\n newLine: candidate.line,\n newEndLine: candidate.endLine,\n newStartColumn: candidate.startColumn,\n newEndColumn: candidate.endColumn,\n reason: \"Exact text match (unique).\",\n };\n }\n\n if (exactCandidates.length > 1 && comment.line != null) {\n const best = closestToLine(exactCandidates, comment.line);\n return {\n commentId,\n status: \"anchored\",\n score: 1.0,\n newLine: best.line,\n newEndLine: best.endLine,\n newStartColumn: best.startColumn,\n newEndColumn: best.endColumn,\n reason: `Exact text match (${exactCandidates.length} occurrences; chose nearest to original line ${comment.line}).`,\n };\n }\n\n const normCandidates = normalizedMatch(documentLines, selectedText);\n if (normCandidates.length === 1) {\n const candidate = normCandidates[0];\n return {\n commentId,\n status: \"fuzzy\",\n score: candidate.score,\n newLine: candidate.line,\n newEndLine: candidate.endLine,\n newStartColumn: candidate.startColumn,\n newEndColumn: candidate.endColumn,\n anchoredText: candidate.text,\n previousSelectedText: selectedText,\n reason: \"Normalized whitespace match.\",\n };\n }\n\n const fuzzyCandidates = fuzzySearch(\n documentLines,\n selectedText,\n HIGH_THRESHOLD,\n comment.line,\n );\n\n if (fuzzyCandidates.length === 1 || (fuzzyCandidates.length > 0 && fuzzyCandidates[0].score >= HIGH_THRESHOLD)) {\n const best =\n fuzzyCandidates.length === 1\n ? fuzzyCandidates[0]\n : closestToLine(fuzzyCandidates, comment.line ?? 1);\n return {\n commentId,\n status: \"fuzzy\",\n score: best.score,\n newLine: best.line,\n newEndLine: best.endLine,\n newStartColumn: best.startColumn,\n newEndColumn: best.endColumn,\n anchoredText: best.text,\n previousSelectedText: selectedText,\n reason: `High-confidence fuzzy match (score ${best.score.toFixed(3)}).`,\n };\n }\n }\n\n if (comment.line != null) {\n const lineIdx = comment.line;\n if (lineIdx > 0 && lineIdx < documentLines.length) {\n const qualifier = opts.commitIsStale\n ? \" (commit is stale \u2014 line may have shifted)\"\n : \"\";\n\n if (selectedText) {\n const lineText = documentLines[lineIdx];\n const candidates = fuzzySearch([\"\", lineText], selectedText, DEFAULT_THRESHOLD);\n if (candidates.length > 0) {\n return {\n commentId,\n status: \"fuzzy\",\n score: candidates[0].score,\n newLine: comment.line,\n newEndLine: comment.end_line,\n anchoredText: candidates[0].text,\n previousSelectedText: selectedText,\n reason: `Line-fallback with fuzzy text match (score ${candidates[0].score.toFixed(3)})${qualifier}.`,\n };\n }\n }\n\n const isLineOnly = !selectedText;\n return {\n commentId,\n status: isLineOnly ? \"anchored\" : (opts.commitIsStale ? \"ambiguous\" : \"anchored\"),\n score: isLineOnly ? 1.0 : (opts.commitIsStale ? 0.5 : 0.8),\n newLine: comment.line,\n newEndLine: comment.end_line,\n reason: isLineOnly\n ? \"Line-only comment (no selected_text to verify).\"\n : `Line/column fallback${qualifier}.`,\n };\n }\n }\n\n if (selectedText) {\n const lowCandidates = fuzzySearch(\n documentLines,\n selectedText,\n threshold,\n comment.line,\n );\n\n if (lowCandidates.length === 1) {\n const candidate = lowCandidates[0];\n return {\n commentId,\n status: \"fuzzy\",\n score: candidate.score,\n newLine: candidate.line,\n newEndLine: candidate.endLine,\n newStartColumn: candidate.startColumn,\n newEndColumn: candidate.endColumn,\n anchoredText: candidate.text,\n previousSelectedText: selectedText,\n reason: `Low-threshold fuzzy match (score ${candidate.score.toFixed(3)}).`,\n };\n }\n\n if (lowCandidates.length > 1) {\n const best = lowCandidates[0];\n return {\n commentId,\n status: \"ambiguous\",\n score: best.score,\n newLine: best.line,\n newEndLine: best.endLine,\n reason: `Ambiguous: ${lowCandidates.length} fuzzy matches (best score ${best.score.toFixed(3)}).`,\n };\n }\n }\n\n return {\n commentId,\n status: \"orphaned\",\n score: 0,\n reason: \"No match found. Comment is orphaned.\",\n };\n}\n\nexport function reanchorDocumentLines(\n doc: MrsfDocument,\n documentLines: string[],\n opts: { threshold?: number } = {},\n): ReanchorResult[] {\n return doc.comments.map((comment) => reanchorComment(comment, documentLines, opts));\n}\n\nexport function reanchorDocumentText(\n doc: MrsfDocument,\n documentText: string,\n opts: { threshold?: number } = {},\n): ReanchorResult[] {\n return reanchorDocumentLines(doc, toReanchorLines(documentText), opts);\n}\n\nexport function resolveAnchor(\n comment: Comment,\n documentText: string,\n opts: { threshold?: number } = {},\n): AnchorPosition {\n const normalizedText = documentText.replace(/\\r\\n/g, \"\\n\");\n const documentLines = toReanchorLines(documentText);\n const result = reanchorComment(comment, documentLines, opts);\n\n if (result.status === \"orphaned\") {\n return {\n status: \"orphaned\",\n score: result.score,\n reason: result.reason,\n };\n }\n\n const line = result.newLine ?? comment.line;\n if (line == null) {\n return {\n status: result.status,\n score: result.score,\n reason: result.reason,\n };\n }\n\n const rawLines = normalizedText.split(\"\\n\");\n const lineStarts = computeLineStarts(rawLines);\n const endLine = result.newEndLine ?? comment.end_line ?? line;\n const startColumn = result.newStartColumn ?? comment.start_column ?? 0;\n const endColumn = result.newEndColumn ?? comment.end_column;\n const from = offsetFor(lineStarts, rawLines, line, startColumn);\n const selectedText = comment.selected_text?.replace(/\\r\\n/g, \"\\n\");\n const to =\n endColumn != null\n ? offsetFor(lineStarts, rawLines, endLine, endColumn)\n : selectedText\n ? from + selectedText.length\n : offsetFor(lineStarts, rawLines, endLine, rawLines[endLine - 1]?.length ?? 0);\n\n return {\n status: result.status,\n score: result.score,\n from,\n to,\n line,\n endLine,\n startColumn,\n endColumn: endColumn ?? columnForOffset(lineStarts, rawLines, endLine, to),\n reason: result.reason,\n };\n}\n\nfunction computeLineStarts(lines: string[]): number[] {\n const starts = [0];\n let offset = 0;\n for (const line of lines) {\n starts.push(offset);\n offset += line.length + 1;\n }\n return starts;\n}\n\nfunction offsetFor(\n lineStarts: number[],\n lines: string[],\n line: number,\n column: number,\n): number {\n const start = lineStarts[line] ?? 0;\n const maxColumn = lines[line - 1]?.length ?? 0;\n return start + Math.max(0, Math.min(column, maxColumn));\n}\n\nfunction columnForOffset(\n lineStarts: number[],\n lines: string[],\n line: number,\n offset: number,\n): number {\n const start = lineStarts[line] ?? 0;\n const maxColumn = lines[line - 1]?.length ?? 0;\n return Math.max(0, Math.min(offset - start, maxColumn));\n}\n\nexport function applyReanchorResults(\n doc: MrsfDocument,\n results: ReanchorResult[],\n opts: { updateText?: boolean; force?: boolean; headCommit?: string } = {},\n): number {\n let changed = 0;\n const resultMap = new Map(results.map((result) => [result.commentId, result]));\n\n for (const comment of doc.comments) {\n const result = resultMap.get(comment.id);\n if (!result) continue;\n\n let isChanged = false;\n\n if (result.newLine != null && result.newLine !== comment.line) {\n comment.line = result.newLine;\n isChanged = true;\n }\n if (result.newEndLine != null && result.newEndLine !== comment.end_line) {\n comment.end_line = result.newEndLine;\n isChanged = true;\n }\n if (result.newStartColumn != null && result.newStartColumn !== comment.start_column) {\n comment.start_column = result.newStartColumn;\n isChanged = true;\n }\n if (result.newEndColumn != null && result.newEndColumn !== comment.end_column) {\n comment.end_column = result.newEndColumn;\n isChanged = true;\n }\n\n if (result.anchoredText != null && result.anchoredText !== comment.selected_text) {\n if (opts.updateText) {\n comment.selected_text = result.anchoredText;\n delete comment.anchored_text;\n } else {\n comment.anchored_text = result.anchoredText;\n }\n isChanged = true;\n } else if (result.anchoredText != null && result.anchoredText === comment.selected_text) {\n if (comment.anchored_text) {\n delete comment.anchored_text;\n isChanged = true;\n }\n }\n\n if (isChanged || result.status !== \"anchored\") {\n comment.x_reanchor_status = result.status;\n comment.x_reanchor_score = result.score;\n }\n\n if (\n opts.force\n && opts.headCommit\n && (result.status === \"anchored\" || result.status === \"shifted\")\n && result.score >= HIGH_THRESHOLD\n ) {\n comment.commit = opts.headCommit;\n delete comment.x_reanchor_status;\n delete comment.x_reanchor_score;\n if (comment.anchored_text && comment.anchored_text === comment.selected_text) {\n delete comment.anchored_text;\n }\n isChanged = true;\n }\n\n if (isChanged) {\n changed += 1;\n }\n }\n\n return changed;\n}\n\nfunction extractText(\n lines: string[],\n line: number,\n endLine?: number,\n startColumn?: number,\n endColumn?: number,\n): string | null {\n const startIdx = line;\n const endIdx = endLine ?? line;\n\n if (startIdx < 1 || endIdx >= lines.length) return null;\n\n if (startIdx === endIdx) {\n const text = lines[startIdx];\n if (startColumn != null && endColumn != null) {\n return text.slice(startColumn, endColumn);\n }\n return text;\n }\n\n const result: string[] = [];\n for (let index = startIdx; index <= endIdx; index += 1) {\n let currentLine = lines[index];\n if (index === startIdx && startColumn != null) currentLine = currentLine.slice(startColumn);\n if (index === endIdx && endColumn != null) currentLine = currentLine.slice(0, endColumn);\n result.push(currentLine);\n }\n return result.join(\"\\n\");\n}\n\nfunction closestToLine<T extends { line: number }>(candidates: T[], targetLine: number): T {\n return candidates.reduce((best, candidate) =>\n Math.abs(candidate.line - targetLine) < Math.abs(best.line - targetLine) ? candidate : best,\n );\n}\n\nfunction getLineShift(diffHunks: DiffHunk[], line: number): { shift: number; modified: boolean } {\n let shift = 0;\n let modified = false;\n\n for (const hunk of diffHunks) {\n const oldStart = hunk.oldStart;\n const oldEnd = hunk.oldStart + Math.max(hunk.oldCount, 1) - 1;\n\n if (line >= oldStart && line <= oldEnd && hunk.oldCount > 0) {\n modified = true;\n }\n\n if (line > oldEnd || (hunk.oldCount === 0 && line >= oldStart)) {\n shift += hunk.newCount - hunk.oldCount;\n }\n }\n\n return { shift, modified };\n}", "import AjvModule from \"ajv\";\nimport addFormatsModule from \"ajv-formats\";\nimport { mrsfSchema } from \"./schema.js\";\nimport type {\n MrsfDocument,\n ValidationDiagnostic,\n ValidationResult,\n} from \"./types.js\";\n\nconst Ajv = (AjvModule as any).default ?? AjvModule;\nconst addFormats = (addFormatsModule as any).default ?? addFormatsModule;\n\nexport type HashFunction = (text: string) => string;\n\nexport function validateDocument(\n doc: MrsfDocument,\n schema: object = mrsfSchema,\n): ValidationResult {\n const errors: ValidationDiagnostic[] = [];\n const warnings: ValidationDiagnostic[] = [];\n\n validateSchema(doc, schema, errors);\n validateCrossFields(doc, errors, warnings);\n\n return {\n valid: errors.length === 0,\n errors,\n warnings,\n };\n}\n\nexport function validateSchema(\n doc: MrsfDocument,\n rawSchema: object,\n errors: ValidationDiagnostic[],\n): void {\n const { $schema, ...schema } = rawSchema as Record<string, unknown>;\n void $schema;\n const ajv = new Ajv({ allErrors: true, strict: false });\n addFormats(ajv);\n const ajvValidate = ajv.compile(schema);\n const schemaValid = ajvValidate(doc);\n\n if (!schemaValid && ajvValidate.errors) {\n for (const err of ajvValidate.errors) {\n errors.push({\n severity: \"error\",\n code: \"schema-violation\",\n message: `${err.instancePath || \"/\"}: ${err.message ?? \"schema error\"}`,\n path: err.instancePath || \"/\",\n });\n }\n }\n}\n\nexport function validateCrossFields(\n doc: MrsfDocument,\n errors: ValidationDiagnostic[],\n warnings: ValidationDiagnostic[],\n hash?: HashFunction,\n): void {\n if (!Array.isArray(doc.comments)) return;\n\n const ids = new Set<string>();\n const allIds = doc.comments.map((x) => x.id);\n\n for (let i = 0; i < doc.comments.length; i++) {\n const c = doc.comments[i];\n const prefix = `/comments/${i}`;\n\n if (c.id) {\n if (ids.has(c.id)) {\n errors.push({\n severity: \"error\",\n code: \"duplicate-id\",\n message: `Duplicate comment id \"${c.id}\"`,\n path: `${prefix}/id`,\n commentId: c.id,\n });\n }\n ids.add(c.id);\n }\n\n if (c.line != null && c.end_line != null && c.end_line < c.line) {\n errors.push({\n severity: \"error\",\n code: \"end-line-before-line\",\n message: `end_line (${c.end_line}) must be \u2265 line (${c.line})`,\n path: `${prefix}/end_line`,\n commentId: c.id,\n });\n }\n\n if (\n c.start_column != null &&\n c.end_column != null &&\n (c.line == null || c.end_line == null || c.line === c.end_line) &&\n c.end_column < c.start_column\n ) {\n errors.push({\n severity: \"error\",\n code: \"end-column-before-start-column\",\n message: `end_column (${c.end_column}) must be \u2265 start_column (${c.start_column}) on the same line`,\n path: `${prefix}/end_column`,\n commentId: c.id,\n });\n }\n\n if (c.selected_text && c.selected_text.length > 4096) {\n errors.push({\n severity: \"error\",\n code: \"selected-text-too-long\",\n message: `selected_text exceeds 4096 characters (${c.selected_text.length})`,\n path: `${prefix}/selected_text`,\n commentId: c.id,\n });\n }\n\n if (c.text && c.text.length > 16384) {\n warnings.push({\n severity: \"warning\",\n code: \"text-too-long\",\n message: `text exceeds recommended 16384 characters (${c.text.length})`,\n path: `${prefix}/text`,\n commentId: c.id,\n });\n }\n\n // Browser-safe callers do not get the Node SHA-256 implementation.\n // The hash check runs only when a hash function is injected by the Node validator.\n if (hash && c.selected_text && c.selected_text_hash) {\n const expected = hash(c.selected_text);\n if (c.selected_text_hash !== expected) {\n warnings.push({\n severity: \"warning\",\n code: \"hash-mismatch\",\n message: `selected_text_hash mismatch (expected ${expected.slice(0, 12)}\u2026, got ${c.selected_text_hash.slice(0, 12)}\u2026)`,\n path: `${prefix}/selected_text_hash`,\n commentId: c.id,\n });\n }\n }\n\n if (c.reply_to && !ids.has(c.reply_to) && !allIds.includes(c.reply_to)) {\n warnings.push({\n severity: \"warning\",\n code: \"unresolved-reply-to\",\n message: `reply_to \"${c.reply_to}\" does not resolve to any comment id in this file`,\n path: `${prefix}/reply_to`,\n commentId: c.id,\n });\n }\n\n if (c.line != null && !c.selected_text) {\n warnings.push({\n severity: \"warning\",\n code: \"missing-selected-text\",\n message: \"Comment has line anchors but no selected_text \u2014 anchoring will be fragile across edits\",\n path: `${prefix}/selected_text`,\n commentId: c.id,\n });\n }\n }\n}\n", "\n{\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"$id\": \"https://github.com/wictorwilen/MRSF/raw/main/mrsf.schema.json\",\n \"title\": \"Markdown Review Sidecar Format (MRSF) v1.0\",\n \"description\": \"Schema for MRSF review sidecar files. See MRSF-v1.0.md for the full specification.\",\n \"type\": \"object\",\n \"required\": [\"mrsf_version\", \"document\", \"comments\"],\n \"additionalProperties\": true,\n \"properties\": {\n \"mrsf_version\": {\n \"type\": \"string\",\n \"pattern\": \"^1\\\\.\\\\d+$\",\n \"description\": \"MRSF format version. MUST be a supported major.minor version (e.g., 1.0).\"\n },\n \"document\": {\n \"type\": \"string\",\n \"description\": \"Relative path to the Markdown document being reviewed.\"\n },\n \"comments\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"required\": [\"id\", \"author\", \"timestamp\", \"text\", \"resolved\"],\n \"additionalProperties\": true,\n \"properties\": {\n \"id\": {\n \"type\": \"string\",\n \"description\": \"Globally unique, opaque, collision-resistant identifier for the comment.\"\n },\n \"author\": {\n \"type\": \"string\",\n \"description\": \"Creator of the comment. SHOULD follow the convention 'Display Name (identifier)'.\"\n },\n \"timestamp\": {\n \"type\": \"string\",\n \"format\": \"date-time\",\n \"description\": \"ISO 8601 / RFC 3339 timestamp of comment creation; SHOULD include timezone offset.\"\n },\n \"text\": {\n \"type\": \"string\",\n \"maxLength\": 16384,\n \"description\": \"The content of the review comment. MUST be plain text.\"\n },\n \"resolved\": {\n \"type\": \"boolean\",\n \"description\": \"Whether the comment has been resolved.\"\n },\n \"commit\": {\n \"type\": \"string\",\n \"description\": \"Git commit hash associated with the comment. SHOULD be the full (long) SHA.\"\n },\n \"type\": {\n \"type\": \"string\",\n \"description\": \"Categorization of the comment. Recommended values listed in examples.\",\n \"examples\": [\n \"suggestion\",\n \"issue\",\n \"question\",\n \"accuracy\",\n \"style\",\n \"clarity\"\n ]\n },\n \"severity\": {\n \"type\": \"string\",\n \"description\": \"Importance level of the comment.\",\n \"enum\": [\"low\", \"medium\", \"high\"]\n },\n \"reply_to\": {\n \"type\": \"string\",\n \"description\": \"ID of another comment in the same file that this comment replies to.\"\n },\n \"line\": {\n \"type\": \"integer\",\n \"minimum\": 1,\n \"description\": \"Starting line number (1-based) in the target document.\"\n },\n \"end_line\": {\n \"type\": \"integer\",\n \"minimum\": 1,\n \"description\": \"Ending line number (inclusive, 1-based). MUST be >= line.\"\n },\n \"start_column\": {\n \"type\": \"integer\",\n \"minimum\": 0,\n \"description\": \"Starting column index (0-based) within the starting line.\"\n },\n \"end_column\": {\n \"type\": \"integer\",\n \"minimum\": 0,\n \"description\": \"Ending column index. MUST be >= start_column when on the same line.\"\n },\n \"selected_text\": {\n \"type\": \"string\",\n \"maxLength\": 4096,\n \"description\": \"Exact text selected by the reviewer. SHOULD NOT be modified by re-anchoring tools. SHOULD NOT exceed 4096 characters.\"\n },\n \"anchored_text\": {\n \"type\": \"string\",\n \"maxLength\": 4096,\n \"description\": \"Text currently found at the resolved anchor position. Populated by re-anchoring tools when the document text differs from selected_text. SHOULD be omitted when identical to selected_text.\"\n },\n \"selected_text_hash\": {\n \"type\": \"string\",\n \"pattern\": \"^[a-f0-9]{64}$\",\n \"description\": \"Hex-encoded SHA-256 hash of selected_text. Immutable after creation; used for fast exact-match detection during re-anchoring, integrity verification, and staleness checks. SHOULD NOT be modified by re-anchoring tools unless selected_text is also replaced (opt-in behaviour), in which case it MUST be recomputed.\"\n }\n }\n }\n }\n }\n}\n", "import mrsf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E,mBAAmB,MAAM,GAAG,EAAE,CAAC;AAAA,UAClH,MAAM,GAAG,MAAM;AAAA,UACf,WAAW,EAAE;AAAA,QACf,CAAC;AAAA,MACH;AAAA,IACF;AAEA,QAAI,EAAE,YAAY,CAAC,IAAI,IAAI,EAAE,QAAQ,KAAK,CAAC,OAAO,SAAS,EAAE,QAAQ,GAAG;AACtE,eAAS,KAAK;AAAA,QACZ,UAAU;AAAA,QACV,MAAM;AAAA,QACN,SAAS,aAAa,EAAE,QAAQ;AAAA,QAChC,MAAM,GAAG,MAAM;AAAA,QACf,WAAW,EAAE;AAAA,MACf,CAAC;AAAA,IACH;AAEA,QAAI,EAAE,QAAQ,QAAQ,CAAC,EAAE,eAAe;AACtC,eAAS,KAAK;AAAA,QACZ,UAAU;AAAA,QACV,MAAM;AAAA,QACN,SAAS;AAAA,QACT,MAAM,GAAG,MAAM;AAAA,QACf,WAAW,EAAE;AAAA,MACf,CAAC;AAAA,IACH;AAAA,EACF;AACF;;;AJlJO,IAAMC,iBAAsB;AAC5B,IAAMC,cAAmB;AACzB,IAAMC,eAAoB;AAC1B,IAAMC,oBAAyB;AAC/B,IAAMC,mBAAwB;AAC9B,IAAMC,iBAAsB;AAE5B,IAAMC,wBAAoC;AAC1C,IAAMC,qBAAiC;AACvC,IAAMC,kBAA8B;AACpC,IAAMC,mBAA+B;AACrC,IAAMC,yBAAqC;AAC3C,IAAMC,wBAAoC;AAC1C,IAAMC,iBAA6B;AACnC,IAAMC,mBAA+B;AAErC,IAAMC,oBAAgC;AAGtC,IAAMC,gBAAwB;AAC9B,IAAMC,eAAuB;AAC7B,IAAMC,gBAAwB;",
6
+ "names": ["DEFAULT_THRESHOLD", "HIGH_THRESHOLD", "applyReanchorResults", "combinedScore", "exactMatch", "formatAuthor", "fuzzySearch", "levenshteinScore", "newCommentId", "normalizedMatch", "parseAuthor", "reanchorComment", "reanchorDocumentLines", "reanchorDocumentText", "resolveAnchor", "toReanchorLines", "tokenLcsScore", "validateDocument", "levenshtein", "uuidv4", "AjvModule", "addFormatsModule", "combinedScore", "exactMatch", "fuzzySearch", "levenshteinScore", "normalizedMatch", "tokenLcsScore", "applyReanchorResults", "DEFAULT_THRESHOLD", "HIGH_THRESHOLD", "reanchorComment", "reanchorDocumentLines", "reanchorDocumentText", "resolveAnchor", "toReanchorLines", "validateDocument", "formatAuthor", "parseAuthor", "newCommentId"]
7
+ }
package/dist/browser.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import * as fuzzy from "./lib/fuzzy.js";
2
+ import * as identity from "./lib/identity.js";
2
3
  import * as reanchorCore from "./lib/reanchor-core.js";
3
- export type { Comment, DiffHunk, FuzzyCandidate, MrsfDocument, ReanchorResult, ReanchorStatus, } from "./lib/types.js";
4
+ import * as validateCore from "./lib/validate-core.js";
5
+ import { mrsfSchema } from "./lib/schema.js";
6
+ export type { AnchorPosition, Comment, DiffHunk, FuzzyCandidate, MrsfDocument, ReanchorResult, ReanchorStatus, } from "./lib/types.js";
7
+ export type { ParsedAuthor } from "./lib/identity.js";
4
8
  export declare const combinedScore: typeof fuzzy.combinedScore;
5
9
  export declare const exactMatch: typeof fuzzy.exactMatch;
6
10
  export declare const fuzzySearch: typeof fuzzy.fuzzySearch;
@@ -13,5 +17,11 @@ export declare const HIGH_THRESHOLD = 0.8;
13
17
  export declare const reanchorComment: typeof reanchorCore.reanchorComment;
14
18
  export declare const reanchorDocumentLines: typeof reanchorCore.reanchorDocumentLines;
15
19
  export declare const reanchorDocumentText: typeof reanchorCore.reanchorDocumentText;
20
+ export declare const resolveAnchor: typeof reanchorCore.resolveAnchor;
16
21
  export declare const toReanchorLines: typeof reanchorCore.toReanchorLines;
22
+ export declare const validateDocument: typeof validateCore.validateDocument;
23
+ export { mrsfSchema };
24
+ export declare const formatAuthor: typeof identity.formatAuthor;
25
+ export declare const parseAuthor: typeof identity.parseAuthor;
26
+ export declare const newCommentId: typeof identity.newCommentId;
17
27
  //# sourceMappingURL=browser.d.ts.map
package/dist/browser.js CHANGED
@@ -1,5 +1,8 @@
1
1
  import * as fuzzy from "./lib/fuzzy.js";
2
+ import * as identity from "./lib/identity.js";
2
3
  import * as reanchorCore from "./lib/reanchor-core.js";
4
+ import * as validateCore from "./lib/validate-core.js";
5
+ import { mrsfSchema } from "./lib/schema.js";
3
6
  export const combinedScore = fuzzy.combinedScore;
4
7
  export const exactMatch = fuzzy.exactMatch;
5
8
  export const fuzzySearch = fuzzy.fuzzySearch;
@@ -12,5 +15,11 @@ export const HIGH_THRESHOLD = reanchorCore.HIGH_THRESHOLD;
12
15
  export const reanchorComment = reanchorCore.reanchorComment;
13
16
  export const reanchorDocumentLines = reanchorCore.reanchorDocumentLines;
14
17
  export const reanchorDocumentText = reanchorCore.reanchorDocumentText;
18
+ export const resolveAnchor = reanchorCore.resolveAnchor;
15
19
  export const toReanchorLines = reanchorCore.toReanchorLines;
20
+ export const validateDocument = validateCore.validateDocument;
21
+ export { mrsfSchema };
22
+ export const formatAuthor = identity.formatAuthor;
23
+ export const parseAuthor = identity.parseAuthor;
24
+ export const newCommentId = identity.newCommentId;
16
25
  //# sourceMappingURL=browser.js.map