Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/opencode/src/kilocode/tool/notebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ const render = (kind: "markdown" | "code", text: string) => {
return `<${kind}_cell>\n${body}</${kind}_cell>`
}

export async function open(filepath: string): Promise<Readable | undefined> {
if (path.extname(filepath).toLowerCase() !== ".ipynb") return undefined
export function isFile(filepath: string) {
return path.extname(filepath).toLowerCase() === ".ipynb"
}

export async function open(filepath: string): Promise<Readable> {
const raw = (await Encoding.read(filepath)).text
const data = parse(raw)
if (!object(data) || !Array.isArray(data.cells)) return Readable.from([raw])
Expand Down
3 changes: 1 addition & 2 deletions packages/opencode/src/tool/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,7 @@ export const ReadTool = Tool.define(
// routed through TextStream.withFallback so non-UTF-8 files are decoded via
// iconv. The body otherwise matches upstream.
export async function lines(filepath: string, opts: { limit: number; offset: number }) {
const extracted = await Notebook.open(filepath) // kilocode_change - extract readable notebook cells before paging
if (extracted) return readLines(extracted, opts) // kilocode_change
if (Notebook.isFile(filepath)) return readLines(await Notebook.open(filepath), opts) // kilocode_change - extract readable notebook cells before paging
return TextStream.withFallback(filepath, (stream) => readLines(stream, opts))
}

Expand Down
Loading