MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / readNotebook

Function readNotebook

source code/utils/notebook.ts:166–185  ·  view source on GitHub ↗
(
  notebookPath: string,
  cellId?: string,
)

Source from the content-addressed store, hash-verified

164 * Reads and parses a Jupyter notebook file into processed cell data
165 */
166export async function readNotebook(
167 notebookPath: string,
168 cellId?: string,
169): Promise<NotebookCellSource[]> {
170 const fullPath = expandPath(notebookPath)
171 const buffer = await getFsImplementation().readFileBytes(fullPath)
172 const content = buffer.toString('utf-8')
173 const notebook = jsonParse(content) as NotebookContent
174 const language = notebook.metadata.language_info?.name ?? 'python'
175 if (cellId) {
176 const cell = notebook.cells.find(c => c.id === cellId)
177 if (!cell) {
178 throw new Error(`Cell with ID "${cellId}" not found in notebook`)
179 }
180 return [processCell(cell, notebook.cells.indexOf(cell), language, true)]
181 }
182 return notebook.cells.map((cell, index) =>
183 processCell(cell, index, language, false),
184 )
185}
186
187/**
188 * Maps notebook cell data to tool result block parameters with sophisticated text block merging

Callers 1

callInnerFunction · 0.85

Calls 5

expandPathFunction · 0.85
getFsImplementationFunction · 0.85
jsonParseFunction · 0.85
processCellFunction · 0.85
toStringMethod · 0.65

Tested by

no test coverage detected