mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-10 22:41:14 +00:00
- Created jupyter-notebook-handler.ts with utilities for parsing and handling .ipynb files - Modified applyDiffTool.ts to extract cell content for editing and reconstruct notebook JSON - Modified multiApplyDiffTool.ts to handle Jupyter notebooks in batch operations - Modified writeToFileTool.ts to detect and properly handle notebook content vs raw JSON - Added comprehensive test suite for all notebook operations - Prevents notebook corruption by maintaining proper JSON structure - Supports both extracted content editing and direct JSON editing workflows
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
const fs = require("fs").promises
|
|
const path = require("path")
|
|
|
|
// Simple test to verify the Jupyter notebook handler works
|
|
async function testJupyterHandler() {
|
|
try {
|
|
// Import the handler functions
|
|
const {
|
|
isJupyterNotebook,
|
|
parseJupyterNotebook,
|
|
applyChangesToNotebook,
|
|
writeJupyterNotebook,
|
|
validateJupyterNotebookJson,
|
|
} = require("./src/core/tools/jupyter-notebook-handler.ts")
|
|
|
|
console.log("✓ Jupyter notebook handler imported successfully")
|
|
|
|
// Test isJupyterNotebook
|
|
console.log("Testing isJupyterNotebook...")
|
|
console.log("test.ipynb:", isJupyterNotebook("test.ipynb")) // should be true
|
|
console.log("test.py:", isJupyterNotebook("test.py")) // should be false
|
|
|
|
// Test validateJupyterNotebookJson
|
|
console.log("Testing validateJupyterNotebookJson...")
|
|
const validNotebook = JSON.stringify({
|
|
cells: [],
|
|
metadata: {},
|
|
nbformat: 4,
|
|
nbformat_minor: 2,
|
|
})
|
|
const validation = validateJupyterNotebookJson(validNotebook)
|
|
console.log("Valid notebook validation:", validation)
|
|
|
|
console.log("✓ All basic tests passed")
|
|
} catch (error) {
|
|
console.error("✗ Test failed:", error.message)
|
|
process.exit(1)
|
|
}
|
|
}
|
|
|
|
testJupyterHandler()
|