mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-01 15:32:11 +08:00
Merge branch 'main' into jetbrains/release/v7.0.1-rc.4
This commit is contained in:
@@ -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])
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user