MCPcopy Index your code
hub / github.com/deepnote/deepnote / handleDiff

Function handleDiff

packages/mcp/src/tools/reading.ts:521–587  ·  view source on GitHub ↗
(args: Record<string, unknown>)

Source from the content-addressed store, hash-verified

519}
520
521async function handleDiff(args: Record<string, unknown>) {
522 const parsedArgs = diffArgsSchema.safeParse(args)
523 if (!parsedArgs.success) {
524 return {
525 content: [{ type: 'text', text: 'path1 and path2 are required and must be strings' }],
526 isError: true,
527 }
528 }
529 const { path1, path2 } = parsedArgs.data
530
531 let file1: DeepnoteFile
532 let file2: DeepnoteFile
533 try {
534 file1 = await loadDeepnoteFile(path1)
535 file2 = await loadDeepnoteFile(path2)
536 } catch (error) {
537 const message = error instanceof Error ? error.message : String(error)
538 return {
539 content: [{ type: 'text', text: `Failed to diff files: ${message}` }],
540 isError: true,
541 }
542 }
543
544 const differences: string[] = []
545
546 // Compare project names
547 if (file1.project.name !== file2.project.name) {
548 differences.push(`Project name: "${file1.project.name}" vs "${file2.project.name}"`)
549 }
550
551 // Compare notebook counts
552 if (file1.project.notebooks.length !== file2.project.notebooks.length) {
553 differences.push(`Notebook count: ${file1.project.notebooks.length} vs ${file2.project.notebooks.length}`)
554 }
555
556 // Compare notebooks by name
557 const notebooks1 = new Map(file1.project.notebooks.map(n => [n.name, n]))
558 const notebooks2 = new Map(file2.project.notebooks.map(n => [n.name, n]))
559
560 for (const [name, nb1] of notebooks1) {
561 const nb2 = notebooks2.get(name)
562 if (!nb2) {
563 differences.push(`Notebook "${name}" only in first file`)
564 } else if (nb1.blocks.length !== nb2.blocks.length) {
565 differences.push(`Notebook "${name}": ${nb1.blocks.length} blocks vs ${nb2.blocks.length} blocks`)
566 }
567 }
568
569 for (const [name] of notebooks2) {
570 if (!notebooks1.has(name)) {
571 differences.push(`Notebook "${name}" only in second file`)
572 }
573 }
574
575 const result = {
576 file1: path1,
577 file2: path2,
578 differenceCount: differences.length,

Callers 1

handleReadingToolFunction · 0.85

Calls 1

loadDeepnoteFileFunction · 0.50

Tested by

no test coverage detected